proto_fighter/Assets/Scripts/EnemyLogic.cs

34 lines
773 B
C#

using UnityEngine;
public class EnemyLogic : InputBase
{
private Transform _transform;
private float _currentDirection;
public Transform target;
private void Start()
{
_transform = transform;
}
private void Update()
{
var horizontalDistance = target.position.x - _transform.position.x;
if (Mathf.Abs(horizontalDistance) > 1.8f)
{
_currentDirection = horizontalDistance / Mathf.Abs(horizontalDistance);
}
else
{
_currentDirection = -horizontalDistance / Mathf.Abs(horizontalDistance);
AttackCallback(AttackState.Heavy);
}
}
public override float GetMovementDirection()
{
return _currentDirection;
}
}