Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to rotate 3d object smoothly using swipes

2powerofn2powerofn Member
edited May 2020 in Programming

3:20PM edited 3:31PM in Programming Flag

How to implement this rotation mechanics in Unity?

I've tried Adding Torque to rigid body, it works but not as perfect as in the video

Here is the example of using torque

float rotX = Input.GetAxis("Mouse X") * rotationSpeed * Mathf.Deg2Rad * Time.fixedDeltaTime;
float rotY = Input.GetAxis("Mouse Y") * rotationSpeed * Mathf.Deg2Rad * Time.fixedDeltaTime;

rb.AddTorque (Vector3.down * -rotX);
rb.AddTorque (Vector3.right * rotY);


  • I am not so sure but maybe try transform.rotate instead of rb.AddTorque?

  • It should work as the combination of this to functions. If you hold it should move with rotate functoin, if you swipe it should use torque. I have only one idea, just to hard code)))

Sign In or Register to comment.