c# - How to make enemies follow the player all around the screen in XNA? -
okay, i've got code make enemies follow player in xna game, follow player until player in front of them. if player moves past enemy, stop moving towards him. instead continuously move , down player.
the code i've used this:
vector2 direction = player.position - goblins[i].position; direction.normalize(); vector2 velocity = direction * goblins[i].enemymovespeed; goblins[i].position += velocity;
(ignore goblins bit, i've replaced graphics)
not entirely sure go it, ideas?
tom, hello, how you?
here have 2 examples helped me lot:
- chase & evade (http://xbox.create.msdn.com/en-us/education/catalog/sample/chase_evade) microsoft sample shows how implement several simple behaviors ai, including chasing, evading, , wandering.
- adding field of view enemies (http://robotfootgames.com/xna-tutorials/5-xna-platformer-starter-kit-field-of-view-for-enemies) related number 1 sample , plaformer starter kit
Comments
Post a Comment