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 22 in Programming

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

How to implement this rotation mechanics in Unity?

https://www.youtube.com/watch?v=MxJhV5FvzxU

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);

https://gist.github.com/aibekn/1a2a8acc7602f40ca6deb7cd4dc0c66e

Answers

  • XeramianXeramian Member

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

  • 2powerofn2powerofn Member

    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.