Jump to content
Sign in to follow this  
nullsystems

buildingPos returns...

Recommended Posts

Hi,

Im looking to find the position of a player within a building and then move a AI to that position with the player...essentially as close as possible on the same floor.

Ive noticed alot of AI just hang around outside of buildings when a player is inside.

How can I do this?

I thought of:

_building = nearestBuilding player

_bpos = buildingPos [_building,_x]

But dunno what the _x would do since I have to define a position. Confused.

Share this post


Link to post
Share on other sites

If you just order the AI to move to a position close to the player (like some random position within a given radius), they should be able to find the closest buildingPos on their own. Using the buildingPos command is only really needed when you want to get them to move to one of the specific positions defined in the AI paths, however the AI is capable of navigating these paths on their own when needed. After all, all that buildingPos does is return a position in X,Y,Z coordinates. Just make sure you use a getPos method that returns the proper height AGL of the player so that the AI moves to the correct floor.

Share this post


Link to post
Share on other sites

_ai doMove getPos _unit

Im using that, it returns all three. So thats kind of confusing now sad_o.gif

Share this post


Link to post
Share on other sites

That's because getPos has problems returning proper AGL height when used inside of buildings with multiple floors or pathable roofs. Try using this in place of getPos:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_ai doMove (_unit modelToWorld [0,0,0])

That should give you the correct height of the player. Also, with this method you could use random values in place of the first two 0's to make the position close to but not exactly on the player. Ex:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_ai doMove (_unit modelToWorld [-2+random 4,-2+random 4,0])

Share this post


Link to post
Share on other sites

Interesting, perfect mate. Very clever thank you.

More people should know about that!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×