38 lines
799 B
C#
38 lines
799 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlanetSpin : MonoBehaviour
|
|
{
|
|
[Header("Ïàðàìåòðè îáåðòàííÿ")]
|
|
[Header("Íàõèë îñ³")]
|
|
[Range(0f, 100f)]
|
|
[SerializeField] private float axialTilt = 0.5f;
|
|
|
|
[Header("Øâèäê³ñòü îáåðòàííÿ íàâêîëî îñ³")]
|
|
[Range(0f, 180f)]
|
|
[SerializeField] private float rotationSpeed = 10f;
|
|
|
|
public float RotationSpeed => rotationSpeed;
|
|
|
|
|
|
void Start()
|
|
{
|
|
transform.localRotation = Quaternion.Euler(0f, 0f, axialTilt);
|
|
}
|
|
|
|
public void SetRotationSpeed(float value)
|
|
{
|
|
rotationSpeed = value;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
float rotationThisFrame = rotationSpeed * Time.deltaTime;
|
|
|
|
transform.Rotate(Vector3.up, rotationThisFrame, Space.Self);
|
|
|
|
}
|
|
}
|
|
|