- Home /
Translation of an Object
I have an object that moves from left to right, but i want to be able to rotate the object once the mouse has clicked the object. BUt I still want it to go to the right and left, but after you rotate it the left and right directions are now changed. How do I go about fixing this, or understanding the concepts? Thank you
Vector3 temp = transform.TransformDirection(Vector3.right);
transform.Translate(temp * speed * Time.deltaTime);
TransformDirection converts from the object's local x,y,z directions to the global x,y,z directions. If your object is rotated, then the direction will be rotated. It sounds like you want the object to rotate about its own axis, but to still move along the same axis in global space (to the right in this case). In that case just don't do the TransformDirection. In other words, forget about temp and just use Vector3.right ins$$anonymous$$d.
Your answer
Follow this Question
Related Questions
Translate Point By Vector3 And Angle 1 Answer
Extreme Beginner Scripting Question 1 Answer
Jump to position in front of an object 1 Answer
How to translate an empty? 2 Answers
Move child objects in the opposite direction of parent object 0 Answers