- Home /
transform.Rotate looks choppy
I want to rotate more objects around a common point at the same time (like the planets rotate around the Sun). I rotate them in the Update method
The problem is : I use
if (Input.GetMouseButton(0))
{
transform.Rotate(Vector3.forward, speed * Time.deltaTime);
}
This looks ok in the editor, but on any device it looks choppy, it's not a smooth animation.
How can I make it look smooth ? Should i use physics, make them objects not affected by gravity and apply angular forces to them while the mouse is pressed ?
Answer by smoggach · Aug 20, 2014 at 06:47 PM
Don't use GetMouseButton. Use colliders and OnMouseDown/OnMouseUp
I bet it looks choppy on the device because of what Input.GetMouseButton(0) returns on the device.
Yea, but i need when i hold the button, not just when i press it. Is ther eanything like On$$anonymous$$ouseHold ?
You can turn a boolean to true with On$$anonymous$$ouseDown, And false with On$$anonymous$$ouseUp.
Then if that boolean is true : Spin
I used GetTouch and changed a boolean like jokim suggested and it works pretty well. Thank you