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.

Dark Physics & Dark A.I. & Dark Dynamix / RTS pathfinding with Dark A.I

Author
Message
Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 16th Jan 2008 19:50 Edited at: 16th Jan 2008 20:07
Hi!
Im using the
"Ai Entity Go To Position"
for my RTS-game, the problem is that the object goes to the position, stops for a few seconds, then returns to its starting point

How do I get it to stop when it hit the point, so it don't return to it's starting point?

btw, I don't want to set it to
"AI Set Entity Control x,0"
Because then my units won't respond to the enemy with you me controlling every thing.

kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 16th Jan 2008 20:16 Edited at: 16th Jan 2008 20:17
check if its not defending anything and also check if it isnt in stationary mode

Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 16th Jan 2008 21:37 Edited at: 16th Jan 2008 21:43
here is my code
ai start

make object plain 1,100,100
xrotate object 1,90

AUTOCAM OFF

make object sphere 10,2.5 : color object 10,rgb(255,000,000)

make object sphere 2,5
color object 2, rgb(255,000,000)
ai add enemy 2,2

make object sphere 3,5
color object 3, rgb(255,255,000)
ai add enemy 3,3

make object sphere 4,5
color object 4, rgb(255,255,255)
ai add enemy 4,4

make object sphere 5,5
color object 5, rgb(000,255,000)
ai add enemy 5,4

AI Debug Show Paths 2.5

AI Set Entity Speed 2,10
AI Set Entity Speed 3,10
AI Set Entity Speed 4,10
AI Set Entity Speed 5,10

AI Set Entity Patrol Time 2,-10
AI Set Entity Patrol Time 3,-10
AI Set Entity Patrol Time 4,-10
AI Set Entity Patrol Time 5,-10

do

if keystate(2) then selected = 2
if keystate(3) then selected = 3
if keystate(4) then selected = 4
if keystate(5) then selected = 5

pick screen mousex(),mouseY(),1000
vx# = get pick vector x()
vy# = get pick vector y()
vz# = get pick vector z()
dy# = -camera position y()/vy#
vx# = vx#*dy# + camera position x()
vz# = vz#*dy# + camera position z()
position object 10,vx#,0,vz#

picked = pick object (mousex(),mousey(),2,5)
if mouseclick()=1 and picked > 0
selected = picked
endif

if mouseclick()=2 and selected > 0
AI Entity Go To Position selected,object position x(10),object position z(10)
endif

text 000,000,"picked : " + str$(picked)
text 000,015,"selected : " + str$(selected)

ai update
sync
loop

How do I check if it is in stationary mode? (Will check the manual, just in case I don't find the answer I don't have to go back and edit the post... hell' yea im lazy )

After a small search I changed my code to this
ai start

make object plain 1,100,100
xrotate object 1,90

AUTOCAM OFF

make object sphere 10,2.5 : color object 10,rgb(255,000,000)

make object sphere 2,5
color object 2, rgb(255,000,000)
ai add enemy 2,2

make object sphere 3,5
color object 3, rgb(255,255,000)
ai add enemy 3,3

make object sphere 4,5
color object 4, rgb(255,255,255)
ai add enemy 4,4

make object sphere 5,5
color object 5, rgb(000,255,000)
ai add enemy 5,4

AI Debug Show Paths 2.5

AI Set Entity Speed 2,10
AI Set Entity Speed 3,10
AI Set Entity Speed 4,10
AI Set Entity Speed 5,10

AI Set Entity Stance 2,0

do

if keystate(2) then selected = 2
if keystate(3) then selected = 3
if keystate(4) then selected = 4
if keystate(5) then selected = 5

pick screen mousex(),mouseY(),1000
vx# = get pick vector x()
vy# = get pick vector y()
vz# = get pick vector z()
dy# = -camera position y()/vy#
vx# = vx#*dy# + camera position x()
vz# = vz#*dy# + camera position z()
position object 10,vx#,0,vz#

picked = pick object (mousex(),mousey(),2,5)
if mouseclick()=1 and picked > 0
selected = picked
endif

if mouseclick()=2 and selected > 0
AI Entity Go To Position selected,object position x(10),object position z(10)
endif

text 000,000,"picked : " + str$(picked)
text 000,015,"selected : " + str$(selected)

ai update
sync
loop

but it still dosn't work

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 28th Jan 2008 02:35 Edited at: 28th Jan 2008 02:37
Whats happening is you entity is returning to its idle position when it reaches the target location. I don't know how to stop this but what you can do is wait until it reaches the target location then use ai set entity idle position and pass the current position of the entity.

e.g.



This will set the idle position to the current position of the entity, which will prevent it from returning to the start position.

The Sun is trying to kill me!

Login to post a reply

Server time is: 2024-05-20 02:47:02
Your offset time is: 2024-05-20 02:47:02