Fix vehicle reset logic
parent
a86b2d8434
commit
cc22ddb37b
|
@ -27,8 +27,13 @@ func spawn_player(player_node: Node, gui: Node) -> void:
|
||||||
|
|
||||||
|
|
||||||
func reset_player_to(node_to_reset_to: Node, player_node: BuggedVehicle) -> void:
|
func reset_player_to(node_to_reset_to: Node, player_node: BuggedVehicle) -> void:
|
||||||
player_node.reset_transform = node_to_reset_to.global_transform
|
player_node.reset_transform = node_to_reset_to.global_transform.looking_at(
|
||||||
player_node.reset_transform.origin += node_to_reset_to.global_transform.basis.y * 15
|
node_to_reset_to.global_transform.translated(
|
||||||
|
node_to_reset_to.global_transform.basis.z
|
||||||
|
).origin,
|
||||||
|
node_to_reset_to.global_transform.basis.y
|
||||||
|
)
|
||||||
|
player_node.reset_transform.origin += node_to_reset_to.global_transform.basis.y * 5
|
||||||
|
|
||||||
|
|
||||||
func _on_ResetArea_body_entered(body: Node) -> void:
|
func _on_ResetArea_body_entered(body: Node) -> void:
|
||||||
|
|
|
@ -71,6 +71,8 @@ func _ready():
|
||||||
func _integrate_forces(state: PhysicsDirectBodyState) -> void:
|
func _integrate_forces(state: PhysicsDirectBodyState) -> void:
|
||||||
if reset_transform != Transform.IDENTITY:
|
if reset_transform != Transform.IDENTITY:
|
||||||
state.set_transform(reset_transform)
|
state.set_transform(reset_transform)
|
||||||
|
state.linear_velocity = Vector3.ZERO
|
||||||
|
state.angular_velocity = Vector3.ZERO
|
||||||
reset_transform = Transform.IDENTITY
|
reset_transform = Transform.IDENTITY
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue