32 lines
951 B
C#
32 lines
951 B
C#
using Syntriax.Modules.Movement.ColliderTrigger;
|
|
using UnityEngine;
|
|
|
|
namespace Syntriax.Modules.Movement.Implementations.TwoDimensional
|
|
{
|
|
public class OneDirectional2DGroundMovement : OneDirectional2DMovementBase
|
|
{
|
|
protected override float moveValue { get; set; } = 0f;
|
|
protected IGroundTrigger groundTrigger = null;
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
groundTrigger = GetComponentInChildren<IGroundTrigger>();
|
|
groundTrigger.OnTriggered += OnGroundTrigger;
|
|
}
|
|
|
|
private void OnGroundTrigger(bool isGrounded)
|
|
=> CanTakeOver = isGrounded;
|
|
|
|
public override void ApplyMovement()
|
|
{
|
|
Vector2 velocity = rigid.velocity;
|
|
velocity.x = moveValue;
|
|
rigid.velocity = velocity;
|
|
}
|
|
|
|
protected override void OnDeactivated() { }
|
|
protected override void OnActivated() { }
|
|
}
|
|
}
|