AIPath script 2D sprite moving incorrectly

Hello, I’ve got a problem that I can’t solve with my enemy, the A* is working fine it’s just that the 2d flat sprite of enemy is moving towards the player with his side, I needed to change two things in the AIPath script to get him moving i changed: euler.x = 90 and Vector3 forward = dir. What should I change in AIPath to make him move forward properly, help me please.

http://pl.tinypic.com/r/2cep2jm/8

http://pl.tinypic.com/r/2e1cc8y/8

Hi

Does this help you?

Thanks for the quick reply, with the first script you have mentioned enemy object is moving to target but also rotating all the time in a circle. The second script is also making him move in a circle. I’ll try to play with the settings…

The second script AIPath2DTopDown is working in some way, if I turn off and on again the value “rotate in 2d” in editor the sprite is heading towards the goal with his front but he is upside down. And I have to do this “rotate in 2dd” rotate on/off to make it work. Please look:

http://pl.tinypic.com/r/5b3gk6/8

You should put the sprite as a child object of the controller and rotate that. All movement scripts assume that the Z axis is the forward axis.

I got it working with the AIPath script, your idea to make sprite a child component/object and rotate that helped me greatly! Thanks

1 Like

if you dont mind, i’ll just post in here…

i cant get my sprite to move… for some reason? and i have no idea why, i tried with rigidbody 2d, i tried doing that child thing, but probably incorrectly, can you post screenshots of how it should be?

player is that cabinet on left, and target is that exclamation mark to the right.

screenshot: http://i.imgur.com/Nlycaeo.jpg

Hey, for me the AIPath script and the two posted by Aron worked, my problem was to set sprite movement correctly but it was moving. And my game is a top down 3d and your’s is 2d? I think I can’t help you, try scripts posted by Aaron and play with settings.

1 Like

AIPath2DTopDown does not have a target set.