blob: 1082b2d8e44b4939f5b915e6e14c89d5cb913184 (
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
|
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_impulse(Vector2(10, 10), Vector2(500, -800))
do_reset = false
func _input(event):
if event.is_action_pressed("shoot"):
do_reset = true
|