LookRotation moves GameObject
GameObject scale 1/2/1 all fine, but 1/2/0.25 lookRotation push it slowly. When i try lock Rigidbody rotation on X it fine too, but i need this rotation later.
CursorWorldPoint() is just ScreenPointToRay(MousePosition);
if(GetMouseButtonDown(0))
Point1 = CursorWorldPoint();
Point2 = CursorWorldPoint();
lookDir = Point2 - Point1;
Quaternion rot = Quaternion.LookRotation(lookDir.normalized);
rot.x = 0;
rot.z = 0;
transform.rotation = rot;
does the transform have a parent?
why are you zeroing out the x and z of a quaternion? I usually convert them to Euler with EulerAngle before I do anything like that.
Parent is empty gameObject. I dont need this slow moving, i want just rotation on Y.
I try to convert to euler angles and use transform.eulerAngles, its rotates on Y but still moving.
Does the parent move at all? Does the object or it's parent have a rigidbody that could be being moved by physics?
ensure that the empty gameobject has 1/1/1 scale. Empties should never get scaled.
I think solved. This happen because using Transform on GameObject with Rigidbody.
Answer by SarperS · Jun 23, 2016 at 01:34 PM
Quaternions don't represent the orientation like the euler angles do. Changing their components won't produce the desired results. Maybe try below?
Point2 = CursorWorldPoint();
lookDir = Point2 - Point1;
Quaternion rot = Quaternion.LookRotation(lookDir.normalized);
transform.rotation = rot;
transform.eulerAngles.x = 0;
transform.eulerAngles.z = 0;
Your answer
Follow this Question
Related Questions
What scale value is necessary for get 1\2 part of the original? 1 Answer
Spawning multiple gameobjects with random scales 2 Answers
Object doesn't rotate well with camera raycasting. 0 Answers
Smooth No Gimbal Lock Analogue Rotation 1 Answer
My GameObject disappears when running this script. 0 Answers