How do I get an arrow to point towards an enemy in unity once instantiated?
I am currently creating a tower defense game and I am currently struggling with the rotation of my arrows. I am able to instantiate them fine, but when it comes to their rotation I have tried a lot of things with no success. I am wanting to set the direction of the arrow to point towards the nearest enemy currently on the map, I am able to find the nearest enemy on the map, that is no problem, I'm just struggling on setting the rotation. I have changed the pivot within my sprite editor to be the tip of the arrow, but this had not helped with my situation.
I have tried everything from using Quaternion.Euler's to Transform.Lookat() with no success.
This is what I am using for my arrow movement: Any help would be greatly appreciated :)
Answer by nns2009 · Dec 14, 2018 at 11:04 PM
Not expert on Unity rotation methods but if the resulting arrow in one of your methods points 90 degrees compared to the desired direction (or if it points the opposite direction) that it's worth checking out what axis arrow points to in the model. It might point towards X/Y/Z while Transform.LookAt works for another axis.
I've looked at it whilst the arrow is travelling towards the enemy and the arrow only rotates in the X and Y axis, and I need it to rotate in the Z axis. I think the main problem now is having to calculate the Z angle between the firing point and enemy.
Your answer
Follow this Question
Related Questions
Removing items from list by OnTriggerExit 2 Answers
How to make FunRace3D Style Player-Target Distance with UI 0 Answers
Raycast only occurs on start 2 Answers
Grabbing the Relative eulerAngles.y of a Rotation 1 Answer
Cannot cast Source from Type 2 Answers