1
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityStandardAssets.Characters.FirstPerson; public class RotateObject : MonoBehaviour { public float turningRate = 1; void Awake() { fpcscript = transform.GetComponent<FirstPersonController>(); fpcscript.enabled = false; } void Update() { transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 0, 0), turningRate * Time.deltaTime); } } 

Using Lerp make it rotating but with some stuttering when rotating it's not so smooth.

I also tried first to use Quaternion.RotateTowards instead Lerp but it was too slow and not smooth either.

2 Answers 2

1

I'm uncertain that you were asking for a specific way; Though in unity3d I created a basic way so that you can just attach a script and set the values. Within the inspector it should ask for values to rotate on [X, Y, Z] It uses time.deltaTime and basic Vector's that allow a smooth rotation. This is the best that I could come up with as I'm uncertain if you're asking for a specific way as I may be able to help if you do.

using UnityEngine; public class RotateObject : MonoBehaviour { public float RotationSpeedX; public float RotationSpeedY; public float RotationSpeedZ; public void Update() { Vector3 RotationSPD = new Vector3(RotationSpeedX, RotationSpeedY, RotationSpeedZ); Rotate_Object(RotationSPD); } private void Rotate_Object (Vector3 Rotation_Speed) { transform.Rotate(Rotation_Speed * Time.deltaTime); } } 
Sign up to request clarification or add additional context in comments.

Comments

1

transform.Rotate(Speed * Time.deltaTime); use this api: Time.deltaTime will make it smooth.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.