diff --git a/addons/guide/guide.gd b/addons/guide/guide.gd index c9aa8f1..26faa90 100644 --- a/addons/guide/guide.gd +++ b/addons/guide/guide.gd @@ -383,5 +383,3 @@ func _update_caches(): # and notify interested parties that the input mappings have changed input_mappings_changed.emit() - - diff --git a/systems/weapon/WeaponSystem.cs b/systems/weapon/WeaponSystem.cs index a6f4f31..903d4a3 100644 --- a/systems/weapon/WeaponSystem.cs +++ b/systems/weapon/WeaponSystem.cs @@ -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(); + } } \ No newline at end of file diff --git a/systems/weapon/weapon.tscn b/systems/weapon/weapon.tscn index ca0db45..f37524a 100644 --- a/systems/weapon/weapon.tscn +++ b/systems/weapon/weapon.tscn @@ -13,6 +13,10 @@ bottom_radius = 0.05 height = 1.0 [node name="Weapon" type="RigidBody3D"] +collision_mask = 2 +continuous_cd = true +contact_monitor = true +max_contacts_reported = 1 script = ExtResource("1_csqwk") [node name="TweenQueueSystem" parent="." instance=ExtResource("2_x1nha")] @@ -24,3 +28,5 @@ shape = SubResource("CylinderShape3D_avini") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) mesh = SubResource("CylinderMesh_x1nha") + +[connection signal="body_entered" from="." to="." method="OnThrownWeaponReachesGround"]