0
\$\begingroup\$

i have a moving agent in gis map that is going to the special Coordinate . with assumption that maximum angel of rotation is predefined, i want the agent turn into specified coordinate (in moving) and then go to that location, what i do for this work please help me.

enter image description here

\$\endgroup\$
1
\$\begingroup\$

Imagine that you would make a vector from the moving agent straight to the target location. Instead of using this new vector as your agent's path, you can update you path slightly every iteration with your angle rotation you mentioned, so that it eventually starts going straight to the location.

Algoritm in steps:

  1. Make a vector from agent to target location
  2. Check which direction gives the smallest angle to rotate to face the target location
  3. Check to see if this angle is below (for example) 10 degrees.

    4a. If it is, simply set the path to the vector you made in step one (to avoid zig-zagging)

    4b. If not, rotate your initial path-vector in this direction with your angle rotation speed.

Granted that your rotation speed is low enough, this will make the agent take a smoother path towards the target location.

Depending on what framework you are working in, a "slerp" or "lerp" function might already be implemented which is very useful!

http://answers.unity3d.com/questions/13869/how-do-i-get-smooth-rotation-to-a-point-in-space.html

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.