i'm going to describe what need to be done... "there are circular areas marked in a map, large areas a person can easily move in to them and out of them" what i'm trying to do is deciding weather the person is moving in to or moving out of that circular area. i can get the user location and see weather it falls inside the circle(weather the person is inside the circle) by pure mathematics theories(theories of circle), but how can we decide weather the person in moving in to the circle or moving out of the circle? please give me some advice guys?
Tell me more
×
Game Development Stack Exchange is a question and answer site for
professional and independent game developers. It's 100% free, no registration required.
|
You can do this by using the dot product of the velocity of your player. First, you need to store your player's velocity and use it to update his position. Then, for each trigger in your level you will test if the user is moving towards the center of the trigger (using the dot product between the velocity and the trigger):
|
|||
|
|
|
Store the position of the person at this frame and the position of the person at the last frame. Measure the distance to the circle center at this frame, and the distance to the circle center at the last frame. If the distance to the circle center at this frame is less than at the last frame, then the person is moving toward the circle, otherwise the person is moving away from the circle. |
|||
|
|
