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.

Newcomers DBPro Corner / Model Walk towards you...

Author
Message
Dark Flame
19
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 22nd Mar 2005 06:06 Edited at: 22nd Mar 2005 06:17
Hey, i basically want some enemies on my matrix to walk towords me...but only the ones that are close. But the ones that arnt close i just want them to move around randomily..Does anyone know how to do this? A snipet of code would be great.

Thanks

anomer
19
Years of Service
User Offline
Joined: 11th Oct 2004
Location: City of Tears
Posted: 22nd Mar 2005 06:14
you can get the distance between two objects with the length vector command. not that i remember how off the top of my head. Once you find your distance it's mostly just IF statements to direct your guys

~astro
(stands for astronomer in case you cared )
Baggers
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Yonder over dem dere hills
Posted: 22nd Mar 2005 06:41
These are commands i use to find the distance, it comes in 3 flavours.



So as anomer said if 'distance of enemy to player<enemyrange then turn enemy at character and move him towards player.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 22nd Mar 2005 11:21
OR

You could have a sphere around your character, and then have the computer check every loop if an a.i enters this sphere. If so move the a.i towards you, otherwise choose a random direction and have them move in that direction, along with randomly stopping.

Causin' RUCCUS whereva' I go.
Spaceman Spiff
20
Years of Service
User Offline
Joined: 27th Jan 2004
Location: Smacking my head on your keyboard.
Posted: 22nd Mar 2005 22:32 Edited at: 22nd Mar 2005 22:34
EDIT: Never mind, I just checked out Baggers stuff and it does the same thing as mine.(Only better.)

Smile, it confuses people.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Mar 2005 01:54
Ruccus' method is much easier to use and understand, but Baggers' method is quite a bit faster if you are trying to squeeze stuff inbetween you frame updates. Even a little faster than baggers is to not sqrt the results. Just compared the squared values: for example, a range of 50 would be 50^2, or 2500. So you would use something like;

If 2500 > ((q#-x#)*(q#-x#) + (w#-y#)*(w#-y#) + (e#-z#)*(e#-z#))
`Turn to enemy
Endif

Using the collision sphere takes about 25-50 times as long as the sqrt method, and the sqrt is about 10 times longer than not using sqrt (general results based on my pc, your actual results may vary ). In some AI calcs though, you will need the sqrt for various reasons.

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Dark Flame
19
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 23rd Mar 2005 02:39
Thats a bit to complecated to start off with, is there a snipet just make my enemies walk around randomily?

Thanks

dre
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: West Side
Posted: 26th Mar 2005 14:27
Dark Flame
19
Years of Service
User Offline
Joined: 15th Feb 2005
Location: England
Posted: 26th Mar 2005 20:14
Thanks ill take a look!

Login to post a reply

Server time is: 2024-09-23 15:41:42
Your offset time is: 2024-09-23 15:41:42