Add knockback to secondary attack
This commit is contained in:
@@ -16,6 +16,8 @@ namespace GameJamDungeon
|
||||
|
||||
public float GetRightStrafeInputVector();
|
||||
|
||||
public void ApplyCentralImpulseToPlayer(Vector3 velocity);
|
||||
|
||||
event Player.InventoryButtonPressedEventHandler InventoryButtonPressed;
|
||||
event Player.MinimapButtonHeldEventHandler MinimapButtonHeld;
|
||||
event Player.PauseButtonPressedEventHandler PauseButtonPressed;
|
||||
@@ -71,6 +73,9 @@ namespace GameJamDungeon
|
||||
|
||||
private bool reduceOnTick = true;
|
||||
|
||||
private float _knockbackStrength = 0.0f;
|
||||
private Vector3 _knockbackDirection = Vector3.Zero;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
@@ -121,8 +126,10 @@ namespace GameJamDungeon
|
||||
PlayerBinding
|
||||
.Handle((in PlayerLogic.Output.MovementComputed output) =>
|
||||
{
|
||||
_knockbackStrength = _knockbackStrength * 0.9f;
|
||||
Transform = Transform with { Basis = output.Rotation };
|
||||
Velocity = output.Velocity;
|
||||
Velocity = output.Velocity + (_knockbackDirection * _knockbackStrength);
|
||||
MoveAndSlide();
|
||||
})
|
||||
.Handle((in PlayerLogic.Output.Animations.Attack output) =>
|
||||
{
|
||||
@@ -184,7 +191,6 @@ namespace GameJamDungeon
|
||||
PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta));
|
||||
|
||||
SwordSlashAnimation.Position = GetViewport().GetVisibleRect().Size / 2;
|
||||
MoveAndSlide();
|
||||
|
||||
PlayerLogic.Input(new PlayerLogic.Input.Moved(GlobalPosition, GlobalTransform));
|
||||
}
|
||||
@@ -221,6 +227,12 @@ namespace GameJamDungeon
|
||||
throwItem.GlobalRotation = GlobalRotation;
|
||||
}
|
||||
|
||||
public void ApplyCentralImpulseToPlayer(Vector3 velocity)
|
||||
{
|
||||
_knockbackStrength = 115.0f;
|
||||
_knockbackDirection = velocity;
|
||||
}
|
||||
|
||||
public void OnAnimationFinished(StringName animation)
|
||||
{
|
||||
GD.Print("Attack finished");
|
||||
|
||||
Reference in New Issue
Block a user