blob: 8cf169d3f82d1f4bc001b66bf41f559d62ca1cad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
extends RigidBody2D
var start_position
var do_reset = true
var is_reset = true
func _ready():
start_position = position
# 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
set_angular_damp(0)
apply_torque_impulse(-1000)
do_reset = false
is_reset = true
func _input(event):
if event.is_action_pressed("shoot"):
if is_reset:
set_angular_damp(-1)
gravity_scale = 1
apply_impulse(Vector2(10, 10), Vector2(500, -800))
is_reset = false
else:
gravity_scale = 0
do_reset = true
|