Moving away from or towards the player

Started by
13 comments, last by SimonH 13 years ago
Thank you both very much for explaining that!

So to move away from the player I would calculate the distance between the two, normalize this and then reverse it to give me the opposite direction?
Advertisement

Thank you both very much for explaining that!

So to move away from the player I would calculate the distance between the two, normalize this and then reverse it to give me the opposite direction?

Pretty much, but it's 'calculate the vector between the two, normalize this (using the distance) and then reverse it to get the opposite direction'.
Stickmen Wars 2 is in development.
Meanwhile try Bloodridge
Thank you both very much for the help, I'll get this implemented now.
Just looking for a bit more added advice here.

I'm adding behavior for the AI to detect if it is too close to another ai, and move accordingly. My problem is that if I happen to get two opposite movement vectors, after I add them the result will be 0. How should one respond in this situation? (for my simulation the ai will simply explode, but I mean this as a broader question, if I were doing simulation for example)
No easy answers there! Try looking at the red3D steering examples for some ideas.
Stickmen Wars 2 is in development.
Meanwhile try Bloodridge

This topic is closed to new replies.

Advertisement