- Home /
Duplicate Question
Problem snapping object to different normals, but maintaining x axis orientation
I'm working on an editor, where the player can move an object around the editor, snapping it to surface normal. The player can also rotate the object around its X axis. Whenever I try and snap it to the surface normal it matchs all the axis of the normal and I lose the facing that it had before the snap. I've tried a bunch of different things and I've had limited success. I'm obviously missing something.
tempX=targetObject.transform.localRotation.eulerAngles.x; targetObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitNormal); targetObject.transform.Rotate(Vector3.up * -tempX);
targetObject.transform.position = mInputManager.hit.point;
Follow this Question
Related Questions
Problem snapping object to different normals, but maintaining x axis orientation 1 Answer
Rotating to match normal: Quaternion.FromToRotation(player.up, hit.normal) 1 Answer
Quaternion.euler gives me glitch. Why? 1 Answer
Quaternion.Slerp problem... 1 Answer
Gun not rotating with the camera? 1 Answer