GeoJam2021/Assets/Scripts/RotateAroundSelfAxis.cs

28 lines
681 B
C#
Raw Normal View History

2021-07-22 16:23:11 +02:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateAroundSelfAxis : MonoBehaviour
{
public bool right_rotation = true;
2021-07-22 20:09:52 +02:00
[Range(0f, 600f)] [SerializeField] public float speed = 1;
2021-07-22 16:23:11 +02:00
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(right_rotation) {
2021-07-22 16:52:00 +02:00
transform.localRotation *= Quaternion.AngleAxis(speed * Time.deltaTime, new Vector3(0f, 0f, -1f));
2021-07-22 16:23:11 +02:00
} else {
2021-07-22 16:52:00 +02:00
transform.localRotation *= Quaternion.AngleAxis(speed * Time.deltaTime, new Vector3(0f, 0f, 1f));
2021-07-22 16:23:11 +02:00
}
}
}