28 lines
664 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotator : MonoBehaviour
{
[SerializeField]
private Vector3 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 = rotSpeed;
}
// Update is called once per frame
void FixedUpdate()
{
rb.MoveRotation(rb.rotation * Quaternion.Euler(EulerRot * Time.fixedDeltaTime));
}
}