You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
815 B
28 lines
815 B
using UnityEngine;
|
|
|
|
public class Entity : MonoBehaviour
|
|
{
|
|
[SerializeField] Transform centerPivot;
|
|
|
|
public Vector2 LookDirection { get; private set; }
|
|
public Vector2 CenterPivot => centerPivot != null ? (Vector2)centerPivot.position : (Vector2)transform.position;
|
|
|
|
public void ChangeLookDirection(Transform lookTarget)
|
|
{
|
|
ChangeLookDirection((Vector2)lookTarget.position - (Vector2)transform.position);
|
|
}
|
|
|
|
public void ChangeLookDirection(Vector2 lookDirection)
|
|
{
|
|
if (lookDirection.x >= 0)
|
|
{
|
|
LookDirection = Vector2.right;
|
|
transform.rotation = Quaternion.Euler(Vector3.zero);
|
|
}
|
|
else
|
|
{
|
|
LookDirection = Vector2.left;
|
|
transform.rotation = Quaternion.Euler(Global.V3_RotRev);
|
|
}
|
|
}
|
|
}
|