Files
MovementTests/scenes/components/knockback/CKnockback.cs
Minimata cd519e528f
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 55s
Create tag and build when new code gets to main / Test (push) Successful in 7m7s
Create tag and build when new code gets to main / Export (push) Successful in 9m56s
complete project reorganization
2026-02-04 11:20:00 +01:00

27 lines
835 B
C#

using Godot;
using System;
using Movementtests.interfaces;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_wind.png")]
public partial class CKnockback : Node3D, IKnockbackable
{
[Export] public RKnockback RKnockback { get; set;}
private KnockbackRecord _knockbackRecord = null;
public void RegisterKnockback(KnockbackRecord knockbackRecord)
{
_knockbackRecord = knockbackRecord;
}
public Vector3 ComputeKnockback()
{
if (_knockbackRecord == null) return Vector3.Zero;
var knockbackDirection = GlobalPosition - _knockbackRecord.DamageRecord.SourceLocation;
var finalKnockback = knockbackDirection.Normalized() * RKnockback.Modifier * _knockbackRecord.ForceMultiplier;
_knockbackRecord = null;
return finalKnockback;
}
}