removing broken ABC and refactoring enemy movement
This commit is contained in:
33
scenes/movement/CGroundedMovement.cs
Normal file
33
scenes/movement/CGroundedMovement.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
namespace Movementtests.scenes.movement;
|
||||
|
||||
public partial class CGroundedMovement : Node3D, IMoveable
|
||||
{
|
||||
[Export] public RMovement RMovement;
|
||||
|
||||
[Export]
|
||||
public RayCast3D WallInFrontRayCast { get; set; }
|
||||
|
||||
|
||||
public new Vector3 ComputeVelocity(MovementInputs inputs)
|
||||
{
|
||||
var velocity = inputs.Velocity;
|
||||
var target = inputs.TargetLocation;
|
||||
var direction = (target - GlobalPosition).Normalized();
|
||||
|
||||
var targetPlane = new Vector3(target.X, GlobalPosition.Y, target.Z);
|
||||
LookAt(targetPlane);
|
||||
|
||||
velocity.X = direction.X * RMovement.Speed;
|
||||
velocity.Z = direction.Z * RMovement.Speed;
|
||||
|
||||
if (WallInFrontRayCast.IsColliding())
|
||||
velocity.Y = RMovement.Speed;
|
||||
else if (!inputs.isOnFloor)
|
||||
velocity += inputs.gravity * (float)inputs.delta;
|
||||
|
||||
return velocity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user