28 lines
681 B
C#
28 lines
681 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Rotator : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
private float rotSpeed;
|
|
private Vector3 EulerRot;
|
|
[SerializeField]
|
|
private List<Rigidbody> bodies;
|
|
private Rigidbody rb;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
bodies.AddRange(GetComponentsInChildren<Rigidbody>());
|
|
rb = GetComponent<Rigidbody>();
|
|
EulerRot = new Vector3(0, 0, rotSpeed);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void FixedUpdate()
|
|
{
|
|
rb.MoveRotation(rb.rotation * Quaternion.Euler(EulerRot * Time.fixedDeltaTime));
|
|
}
|
|
}
|