Jump to content


Photo

Path Finding


  • Please log in to reply
1 reply to this topic

#1 _174413

_174413

    GMC Member

  • New Member
  • 22 posts
  • Version:GM8

Posted 21 April 2012 - 11:51 PM

I have an object which uses mp_potential_step() to maintain a path to a goal while avoiding solid objects.

I want to have many instances of this object in a room at one time, but I also want these instances to avoid each other too.
Otherwise, they all bunch together and it looks rubbish,

So how would you do this?
Set up a collision event with itself?

Edited by _174413, 22 April 2012 - 12:53 AM.

  • 0

#2 lballaty

lballaty

    GMC Member

  • New Member
  • 83 posts

Posted 04 June 2012 - 11:08 PM

I have an object which uses mp_potential_step() to maintain a path to a goal while avoiding solid objects.

I want to have many instances of this object in a room at one time, but I also want these instances to avoid each other too.
Otherwise, they all bunch together and it looks rubbish,

So how would you do this?
Set up a collision event with itself?


Maybe you can just check the distances and directions of the other instances or say just the instances within a certain range and move in a direction other than toward them until you find a spot from which you can map a path. You could check the vector in the direction of travel and current speed to determine if they're likely to collide and change direction to avoid it and recalculate again. Then once you have a non colliding vector you can calculate your path to your goal again. Of course once you are forced to move off your present path again to avoid a collision you'll have to start all over.

There are some functions to tell you this kind of info. Look up vector, direction and distance in the help it will take you to the right functions. I don't know them off the top of my head.

You could create a temporary invisible object to check to see if it collides with anything in a particular part of the grid and set the path/direction when it doesn't. Of course since the other instances are also doing that it can change any time so you have to keep checking.

distance_to_object(), distance_to_point(), point_direction(), lenghtdir_x/y(), dot_product(),point_distance() can be useful to help make the decision of what to do. I think the easiest thing is to just have each object run independently but your code will have to be smart enough not to get the objects stuck, especially if there are many of them.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users