How to make a object rotate slowly on its y axis?
I'm new to coding in unity and I'm wondering how to make a model rotate slowly on its y axis? What is the code that I should use (javascript)?
Answer by sadzanenyama · Jul 29, 2018 at 11:39 AM
I would recommend using C# as javascript has been removed from unity in the new update. This code should work
using UnityEngine;
public class ExampleClass : MonoBehaviour
{
void Update()
{
// Rotate the object around its local y axis at 1 degree per second
transform.Rotate(Vector3.up* Time.deltaTime);
}
}
Answer by gorkem3455 · Apr 19 at 07:23 PM
[SerializeField] float _degreesPerSecond = 30f;
[SerializeField] Vector3 _axis = Vector3.forward;
void Update ()
{
transform.Rotate( _axis.normalized * _degreesPerSecond * Time.deltaTime );
}
I was trying to rotate a sprite to circle around it's own so i used like this. It's attached to object.
Your answer
Follow this Question
Related Questions
How to rotate cube2 if the script is in cube1? 1 Answer
Have 3 raycast rays on a capsule and rotate them correspondingly 0 Answers
How to clamp transform.RotateAround using Javascript? 1 Answer
How do i make a child not rotate with the parent. But i still want to be able to rotate it? (2D) 0 Answers
Camera Script remove a part. 0 Answers