Initial commit
This commit is contained in:
37
Assets/Materials/Scripts/PlanetSpin.cs
Normal file
37
Assets/Materials/Scripts/PlanetSpin.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user