using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class RotationController : MonoBehaviour
|
|
{
|
|
|
|
#region Read-Only Fields
|
|
public float RotationPeriod => m_RotationPeriod;
|
|
public Vector3 Position => transform.position;
|
|
public Vector3 RotationAxis => m_RotationAxis;
|
|
public float CorrelusStrength => m_correlusStrength;
|
|
#endregion Read-Only Fields
|
|
|
|
[SerializeField]
|
|
private float m_RotationPeriod;
|
|
|
|
[SerializeField]
|
|
private Vector3 m_RotationAxis = Vector3.forward;
|
|
|
|
[SerializeField]
|
|
private float m_correlusStrength = 100;
|
|
|
|
|
|
|
|
public Vector3 getDownDirection(Vector3 objectPosition, bool normalized = true)
|
|
{
|
|
if (normalized)
|
|
return Vector3.ProjectOnPlane((objectPosition - transform.position), m_RotationAxis).normalized;
|
|
else
|
|
return Vector3.ProjectOnPlane((objectPosition - transform.position), m_RotationAxis);
|
|
|
|
}
|
|
|
|
public Vector3 getPerpendicularDirection(Vector3 objectPosition)
|
|
{
|
|
return Vector3.Cross(RotationAxis, getDownDirection(objectPosition)).normalized;
|
|
}
|
|
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
//transform.Rotate(m_RotationAxis, 360 / m_RotationPeriod * Time.fixedDeltaTime);
|
|
}
|
|
|
|
|
|
}
|