gd: weapon plants itself on landing
This commit is contained in:
@ -383,5 +383,3 @@ func _update_caches():
|
|||||||
|
|
||||||
# and notify interested parties that the input mappings have changed
|
# and notify interested parties that the input mappings have changed
|
||||||
input_mappings_changed.emit()
|
input_mappings_changed.emit()
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
|
|
||||||
public void PlantWeaponInWall()
|
public void PlantWeaponInWall()
|
||||||
{
|
{
|
||||||
|
Freeze = true;
|
||||||
GlobalPosition = _plantLocation;
|
GlobalPosition = _plantLocation;
|
||||||
LookAt(GlobalTransform.Origin + _plantNormal, Vector3.Up, true);
|
LookAt(GlobalTransform.Origin + _plantNormal, Vector3.Up, true);
|
||||||
}
|
}
|
||||||
@ -63,4 +64,19 @@ public partial class WeaponSystem : RigidBody3D
|
|||||||
Transform = _startTransform;
|
Transform = _startTransform;
|
||||||
Freeze = true;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,6 +13,10 @@ bottom_radius = 0.05
|
|||||||
height = 1.0
|
height = 1.0
|
||||||
|
|
||||||
[node name="Weapon" type="RigidBody3D"]
|
[node name="Weapon" type="RigidBody3D"]
|
||||||
|
collision_mask = 2
|
||||||
|
continuous_cd = true
|
||||||
|
contact_monitor = true
|
||||||
|
max_contacts_reported = 1
|
||||||
script = ExtResource("1_csqwk")
|
script = ExtResource("1_csqwk")
|
||||||
|
|
||||||
[node name="TweenQueueSystem" parent="." instance=ExtResource("2_x1nha")]
|
[node name="TweenQueueSystem" parent="." instance=ExtResource("2_x1nha")]
|
||||||
@ -24,3 +28,5 @@ shape = SubResource("CylinderShape3D_avini")
|
|||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
|
||||||
mesh = SubResource("CylinderMesh_x1nha")
|
mesh = SubResource("CylinderMesh_x1nha")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="OnThrownWeaponReachesGround"]
|
||||||
|
Reference in New Issue
Block a user