Godot Version
4.2 Mono
Question
There is an arrow prefab, when fired it creates a new exemplpyre and flies towards the mouse. The logic of the arrow is simple: Hit - Caused damage to the enemy, then removed itself. Out of the screen - removed.
However, instead of deleting, the arrow simply “freezes behind the screen” and when I approach it, it “comes back to life”. That is, the arrow flies while I look at it, otherwise it “freezes”.
arrow script:
public override void _PhysicsProcess(double delta)
{
if (attackComponent.HasOverlappingAreas())
{
attackComponent.EmitSignal(AttackComponent.SignalName.Attack, projectileResource.attackResource);
this.QueueFree();
}
if (!visibleOnScreenEnabler2D.IsOnScreen())
{
this.QueueFree();
}
movementComponent.Move(this);
}
movement script:
public void Move(Projectile projectile)
{
projectile.GlobalPosition += Speed * Direction * Convert.ToSingle(GetPhysicsProcessDeltaTime());
}