W
W
WalVix2020-12-30 18:34:49
Unity
WalVix, 2020-12-30 18:34:49

How to rotate an object around its axis (y)?

Tell me how to rotate an object around the Y axis in Unity3d. There is such a script, but the object rotates diagonally

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateEarth : MonoBehaviour
{
    [SerializeField] public float speed = 0; // скорость
  
    void Update()
    {
        transform.Rotate(0, speed * Time.deltaTime, 0); // вращение планеты
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-12-31
@XTerris

transform.Rotate(0, speed * Time.deltaTime, 0, Space.Self);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question