- Home /
Question by
katsuragi545 · May 19, 2016 at 03:57 AM ·
rotationplatformerrotate objectflight
Setting rotation but with an offset.
I'm currently making an object rotate around based on user input using the following code (a slightly modified bit of code from MouseOrbit:
void HandleSwimRotate()
{
rotX += Input.GetAxis("Horizontal") * xRotSpeed * 0.02f;
rotY -= Input.GetAxis("Vertical") * -yRotSpeed * 0.02f;
rotY = ClampAngle(rotY, yRotMinLimit, yRotMaxLimit);
var rotation = Quaternion.Euler(rotY, rotX, 0);
transform.rotation = rotation;
}
This works as expected, but the center of the object (a humanoid character) is at it's feet. I would like to rotate the player around it's center. Is there anyway to set the rotation with an offset without changing the center point?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612081109im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to rotate a gameobject in a given direction and stop when it's done 1 Answer
Translate speed keeps changing 1 Answer
Player rotation not working correctly after using moving platform 0 Answers
how to make a detect rotation script for negative rotation too 2 Answers
Rotate character in 3D platformer 1 Answer