From f16a77d9137fa458b7af3e0c33361a1218159c1e Mon Sep 17 00:00:00 2001 From: Logan Date: Fri, 23 Sep 2022 18:30:44 -0600 Subject: Refactored physics code. --- Basketball.gd | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Basketball.gd b/Basketball.gd index d4abf21..1082b2d 100644 --- a/Basketball.gd +++ b/Basketball.gd @@ -1,22 +1,21 @@ extends RigidBody2D var start_position - var do_reset = false # Called when the node enters the scene tree for the first time. func _ready(): start_position = position do_reset = true - + # Override the default physics when we want to manually reset the position and rotation. func _integrate_forces(state): if do_reset: state.transform.origin = start_position state.linear_velocity = Vector2() + state.angular_velocity = 0 - apply_central_impulse(Vector2(500, -800)) - apply_torque_impulse(10000.0) + apply_impulse(Vector2(10, 10), Vector2(500, -800)) do_reset = false -- cgit v1.2.3