[ODE] getting an entity to follow another
Jon Watte (ODE)
hplus-ode at mindcontrol.org
Tue Sep 5 11:45:41 MST 2006
1) get front vector of current entity and normalize
2) get vector from entity to target and normalize
3) cross product and normalize: That's the axis of rotation.
4) project the target direction vectors to the plane expressed by this
axis, containing the entity position (using forward direction as the "y"
reference vector). This is a dot product and a vector scale/add.
5) use atan2() on the coordinate you get out: That's the angle of rotation
This process is robust for almost all directions, except when the plane
goes singular (i e, the object is already straight ahead).
If you already have the plane (say, the horizontal plane) then step 5 is
all you need.
Cheers,
/ h+
Dan wrote:
> Hi,
>
> My entities in my game have functions goLeft(), goRight() which apply
> dBodyAddRelTorque to steer them, then I add forward force to move
> them.
>
> I want one entity to follow another, how do I do this? I only need it
> in the horizontal plane.
>
> I guess something can be done with the first entity's angle and the
> target entity's position.
>
> But I have no idea how to get the bearing to the target position or to
> get the entities angle from its matrix or quaternion or how to compare
> them if I could...
>
> Any help appreciated!
>
> Thanks,
>
> Dan
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
>
>
More information about the ODE
mailing list