- Home /
How to rotate object not from it's center point but from it's another point?
I am new in unity and I am developing a game where I want to rotate my object I try this code for it.
if(Input.GetMouseButton(0)){
if(Input.GetMouseButtonDown(0)){
LastMousePosition = Input.mousePosition;
}
else if(LastMousePosition.y> 112){
Bow.Rotate(Vector3.up*(Input.mousePosition.y - LastMousePosition.y));
}
else if(LastMousePosition.y<112){
Bow.Rotate(Vector3.down*(Input.mousePosition.y - LastMousePosition.y));
}
LastMousePosition = Input.mousePosition;
}
It works fine for me but my object is rotate from It's center point and I want to rotate it from another point can any one help me with this?
Thanks in advance..
Regards,
Answer by HarshadK · Sep 16, 2014 at 07:24 AM
If you want to rotate the object around a point that lies within the bounds of that object itself you can change the pivot point of that object from center to the location around which you want to move it.
You can change the pivot point of that object in your 3D modelling application and then re-import the model into Unity.
Or you can do it in Unity itself via this editor script: Solving the Pivot problem in Unity.
Also you need to set the rotation to be around 'Pivot'.