gd: weapon plants itself on landing
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user