Jump to content

  • Log In with Google      Sign In   
  • Create Account


Following a path, determining when to move on to the next point


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 JohnnyLightwave   Members   -  Reputation: 142

Like
0Likes
Like

Posted 19 April 2013 - 04:18 PM

Hi all,

 

Using A*, I have an object that is following a list of points.

 

Because the object's speed and actual path is somewhat variable (it only follows the general vicinity of the points), I am looking for a good way to determine if it has passed one point and should move on to the next.

 

I thought I could do this with the dot product, to check the old vector toward the point with the new one, like so:

oldVector=objectTravelVector;
objectTravelVector=chasingPoint-objectPoint;
objectTravelVector.Normalize();

if (oldVector.Dot(objectTravelVector)<0) // Move to next point

It seems like that should work, but I am getting instances of my object circling points and refusing to move on to the next one.  It seems that if I pass the point, my dot product with the previous vector should be negative, and I just say, okay, next, point.

 

Am I doing this wrong?

 

 



Sponsor:

#2 NumberXaero   Prime Members   -  Reputation: 1399

Like
0Likes
Like

Posted 19 April 2013 - 06:21 PM

What if you created a plane out of the target point and the current travel vector, then test if the current object position is on the positive side of the plane, which would mean you passed the target point.



#3 JohnnyLightwave   Members   -  Reputation: 142

Like
0Likes
Like

Posted 20 April 2013 - 02:09 PM

Well, that's kinda what I'm doing, isn't it?

 

If the new vector is in the same direction as the old vector, then my dot should be >0, and if it's in the opposite direction (indicating passing the point), then my dot is <0 ... theoretically.



#4 Álvaro   Crossbones+   -  Reputation: 12886

Like
0Likes
Like

Posted 20 April 2013 - 02:31 PM

You should debug your program and monitor the values of the variables involved and the dot product while you get into the undesired circling behavior. You could also just trigger going to the next point when you are within some radius of the current point (duh).

Depending on the particulars of your game, you may want to start targeting the next point as soon as you have an unobstructed line to it. You can actually skip a bunch of points if you have a line to a later point.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS