Hello everybody. I have been wrestling with this issue for the best part of two days so some guidance/assistance would be much appreciated.
In my 2D project I have an empty object which rotates around the Z axis randomly to represent the wind direction. This is my “windObject”.
Under certain conditions I would like another separate “otherObject” to move in the direction towards the direction the wind is blowing from, but not towards the actual windObject.
As it is a 2D game I do not want the otherObject sprite to actually rotate at all.
So far my thinking has been:
-
I need to store the “windObject” rotation. Either as a Quaternion or as a Vector3 by converting the Quaternion:
windObject.transform.rotation.eulerAngles;
(or do I just store the value inwindObject.transform.rotation.z
??) -
Using that rotation then work out the direction that my otherObject should move in (facing the wind).
-
Then use
transform.translate
to move my otherObject in that direction for as long as I need to. -
I cant just apply a rotation to my otherObject as I don’t want it to do any rotating at all.
I have tried to sum it up in the picture below!
Any help with this would be really appreciated. These Quaternions and Vectors are starting to make my head spin…