Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [LOCKED] help me with my racing AI

Author
Message
phukol
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 9th Jan 2004 19:06
Im using Matedit 1.6b together with DBC. I tried to follow the tutorials posted on this site which makes use of HOTSPOT (e.g. Limit Rush) but i want to make use of MatEdit's zone instead so that the enemy racer will only follow the path designated as zone 1 or zone 2, i manage to make it follow throught the zone in a staight path but the problem is "it is not able to turn left or right when i programmed it to(preety stupid of me)". Can anyone suggest what's wrong? here is the code:

`-----------------------------------
`racing artificial intelligence
`-----------------------------------
function control_player(id)

X=object position x(id)
Z=object position z(id)+36.5
Zone=CheckZone(X,Z)

xPos#=object position x(id)
zPos#=object position z(id)
yAng=object angle y(id)

if zone=1 or zone=2
forward=1
left=0
right=0
backward=0
else

X2=object position x(id)+15
Z2=object position z(id)
Zone2=CheckZone(X2,Z2)
if zone2=1 or zone2=2
` targetXPos=X2
`targetZPos=Z2
right=1
else
` targetXPos=object position x(id)-15
` targetZPos=object position z(id)
left=1
endif

`angle#=atanfull(targetXPos-xPos#,targetZPos-zPos#)-yAng

`work out direction to turn
`if angle#<-180
` left=1
`else
` right=1
endif
move_player(id,forward, backward, left, right)

endfunction

ive included the remarks so that you can see what changes ive tried to made.

phukol
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 10th Jan 2004 00:18
This area is for CODE SNIPPETS only. Please post in another forum.

RPGamer


We need help! Email us! join@eternaldestinyonline.com

Login to post a reply

Server time is: 2024-11-23 23:16:46
Your offset time is: 2024-11-23 23:16:46