Rotacja obiektu 3D za pomocą slidera w Unity

Zakres i ograniczenie obrotu ustawiam na sliderze w inspektorze, a funckja RotateMyObject() jest wywoływana przy każdej zmianie wartości

using UnityEngine;
using UnityEngine.UI;

public class MyObject : MonoBehaviour
{
    Camera cam;
    [SerializeField] Slider rotSlider;

    void Start()
    {
        cam = Camera.main;
    }

    public void RotateMyObject()
    {
        transform.eulerAngles = new Vector3(0f, rotSlider.value, 0f);
    }

}
Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Tutor LMS website.
Scroll to Top