I'm making a tower defense game, and at the moment I have 1 of my enemies in the scene for testing purposes. This enemy uses the following code to face the direction of the next waypoint:
transform.up = target.position - transform.position;
This correctly changes the direction this enemy is facing. However, when I instantiate the same prefab at a spawner, they face the correct way when its up or down, but if they face the opposite direction when they are supposed to face left or right. I have tried flipping the sprite for a quick fix but that hasnt work.
What have I missed?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
138 People are following this question.
2D sprite animation completes before animation
Programs for making 2d graphic spites
2d supporting characters
How can I do an Enemy while He's walking his HEAD always see the Target?
Player doesn't face the correct way in certain cases