stunnable targets on hit

This commit is contained in:
2026-05-15 15:29:24 +02:00
parent a0e99a959f
commit afa335e7bf
19 changed files with 200 additions and 60 deletions

View File

@@ -21,6 +21,8 @@ public partial class CFlyingMovement : Node3D, IMoveable
public Vector3 ComputeVelocity(MovementInputs inputs)
{
if (inputs.IsStunned) return inputs.Velocity.Lerp(Vector3.Zero, (float) inputs.Delta * RMovement.Acceleration);
var velocity = inputs.Velocity;
var spaceState = GetWorld3D().DirectSpaceState;
var target = inputs.TargetLocation;
@@ -28,7 +30,7 @@ public partial class CFlyingMovement : Node3D, IMoveable
// Check if we have a direct line of sight to the player
if (!_movingToDesiredHeight)
{
velocity = velocity.Lerp(direction * RMovement.Speed, (float) inputs.delta * RMovement.Acceleration);
velocity = velocity.Lerp(direction * RMovement.Speed, (float) inputs.Delta * RMovement.Acceleration);
var query = PhysicsRayQueryParameters3D.Create(GlobalPosition, target, TerrainCollision);
var result = spaceState.IntersectRay(query);
@@ -40,7 +42,7 @@ public partial class CFlyingMovement : Node3D, IMoveable
}
else
{
velocity = velocity.Lerp(_randomDirection * RMovement.Speed, (float) inputs.delta * RMovement.Acceleration);
velocity = velocity.Lerp(_randomDirection * RMovement.Speed, (float) inputs.Delta * RMovement.Acceleration);
var groundQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition, GlobalPosition+Vector3.Down*RMovement.TargetHeight, TerrainCollision);
var groundResult = spaceState.IntersectRay(groundQuery);

View File

@@ -19,15 +19,18 @@ public partial class CGroundedMovement : Node3D, IMoveable
var targetPlane = new Vector3(target.X, GlobalPosition.Y, target.Z);
LookAt(targetPlane);
float xAcc = (float) Mathf.Lerp(velocity.X, direction.X * RMovement.Speed, inputs.delta * RMovement.Acceleration);
float zAcc = (float) Mathf.Lerp(velocity.Z, direction.Z * RMovement.Speed, inputs.delta * RMovement.Acceleration);
var targetXSpeed = inputs.IsStunned ? 0 : direction.X * RMovement.Speed;
var targetZSpeed = inputs.IsStunned ? 0 : direction.Z * RMovement.Speed;
float xAcc = (float) Mathf.Lerp(velocity.X, targetXSpeed, inputs.Delta * RMovement.Acceleration);
float zAcc = (float) Mathf.Lerp(velocity.Z, targetZSpeed, inputs.Delta * RMovement.Acceleration);
velocity.X = xAcc;
velocity.Z = zAcc;
if (WallInFrontRayCast.IsColliding())
if (WallInFrontRayCast.IsColliding() && !inputs.IsStunned)
velocity.Y = RMovement.Speed;
else if (!inputs.isOnFloor)
velocity += inputs.gravity * (float)inputs.delta * RMovement.GravityModifier;
else if (!inputs.IsOnFloor)
velocity += inputs.Gravity * (float)inputs.Delta * RMovement.GravityModifier;
return velocity;
}