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 / How do I allow NPCs to only walk around in a specific area?

Author
Message
cyangamer
16
Years of Service
User Offline
Joined: 2nd Jun 2008
Location: Houston, TX, USA
Posted: 14th Oct 2008 03:56
When I'm making an NPC walk around randomly, I still want him to be in the vicinity of where he started. I know you do something like this:


What I specifically want to do is when an NPC leaves his area, I want him just turn around and walk back into his area, going back into the regular move commands once there. If that's overly difficult though, I'm open for a better way.

Currently working on - Enemy AI and Action Battle System

the sig limit needs to be raised...
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 15th Oct 2008 13:05
I think that there are various methods.

test code
cyangamer
16
Years of Service
User Offline
Joined: 2nd Jun 2008
Location: Houston, TX, USA
Posted: 16th Oct 2008 02:35
What if you're using Move Object commands? Here's my function:



The problem with that method is that it's jumpy. I need the model to just return (probably via move object or a similar command) back to any X/Z point that's within the range.

Currently working on - Enemy AI and Action Battle System

the sig limit needs to be raised...
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 16th Oct 2008 12:22
Here's a thread http://forum.thegamecreators.com/?m=forum_view&t=76061&b=1 where there's some code to deal with getting the distance between two points.

Why not store the 'home' location of each NPC and then compare it's current location with its home location using the above code?

The if you're more than a certain distance away, have your NPC turn around and face the home position and start walking towards it. Once he's arrived (or has got close to it), he can start wandering about again.

Login to post a reply

Server time is: 2024-11-25 16:24:24
Your offset time is: 2024-11-25 16:24:24