Files
proto_fighter/Assets/Scripts/EnemyLogic.cs
T
krazzei 505ba54e8e Basic fighting game.
Need kenney art
could do a lot of other shit, combos, jumping, crouching.
Attacking while jumping/crouuching
Balance stuff
Special moves
2021-02-09 20:20:34 -06:00

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;
}
}