Files
MovementTests/components/knockback/CKnockback.cs
Minimata 916a6e7153
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 33s
Create tag and build when new code gets to main / Test (push) Successful in 6m19s
Create tag and build when new code gets to main / Export (push) Successful in 7m39s
some editor icons and a base level scene
2026-01-27 10:35:35 +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;
}
}