gd: weapon plants itself on landing

This commit is contained in:
2025-06-07 09:39:03 +02:00
parent cebf7a1f0b
commit ff61285483
3 changed files with 22 additions and 2 deletions

View File

@ -54,6 +54,7 @@ public partial class WeaponSystem : RigidBody3D
public void PlantWeaponInWall()
{
Freeze = true;
GlobalPosition = _plantLocation;
LookAt(GlobalTransform.Origin + _plantNormal, Vector3.Up, true);
}
@ -63,4 +64,19 @@ public partial class WeaponSystem : RigidBody3D
Transform = _startTransform;
Freeze = true;
}
public override void _IntegrateForces(PhysicsDirectBodyState3D state)
{
base._IntegrateForces(state);
if (!Freeze && state.GetContactCount() > 0)
{
_plantLocation = state.GetContactLocalPosition(0);
_plantNormal = state.GetContactLocalNormal(0);
}
}
public void OnThrownWeaponReachesGround(Node other)
{
PlantWeaponInWall();
}
}