- Home /
solved
Mouse drag get angle
I have a gameobject If i drag it to any direction I want to get the angle in update without my mouse button up, eg If I drag it to left - 180 , else if right 0 , i drag it in any angle it must give the angle accordingly ,
Nothing is comming in my head
basically I have a curvy path I have to drag the car along the path with mouse and car rotate according to the path with polygon collider,I am able to drag the car along the curve but now i have to rotate it according to curve
any help
You've got Event.current.delta, which gives you the mouse movement as a Vector2, which represents pixels moved on the screen. It shouldn't take too much maths to figure out the angle that vector represents.
I am also trying somthing like that I dont know much about Event.current.delta can you explain how can i get the anglebased on the mouse movement wrt any thing Does event.current .delta applicable only for GUI as I am usnig sprites
Answer by suchoparek · Mar 23, 2015 at 03:37 PM
If I have understood correctly, you need to rotate the car accordingly to the path. You could add an empty gameobject just before the car and use Quaternion.LookRotation to make the car look at it.
Thanx I solved it by making the gameobject follow my mouse pointer and and used lookat2d