diff options
author | Logan <logan@cflip.net> | 2022-09-23 19:45:17 -0600 |
---|---|---|
committer | Logan <logan@cflip.net> | 2022-09-23 19:45:17 -0600 |
commit | 8c5a4e206652af1872f9dfb7edcaf65394416a29 (patch) | |
tree | e29ea55749853deb30b3b3146ab5bb5bbb7fcd6a | |
parent | 983a8f75f974ace86a39c5172042c19d2a880652 (diff) |
Toggle between reset position and applying force.
-rw-r--r-- | Basketball.gd | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Basketball.gd b/Basketball.gd index 1082b2d..40d189c 100644 --- a/Basketball.gd +++ b/Basketball.gd @@ -2,23 +2,26 @@ extends RigidBody2D var start_position var do_reset = false +var is_reset = true # 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.transform = Transform2D(0, start_position) state.linear_velocity = Vector2() state.angular_velocity = 0 - - apply_impulse(Vector2(10, 10), Vector2(500, -800)) - + do_reset = false + is_reset = true func _input(event): if event.is_action_pressed("shoot"): - do_reset = true + if is_reset: + apply_impulse(Vector2(10, 10), Vector2(500, -800)) + is_reset = false + else: + do_reset = true |