gears: made balls despawn after 5 seconds #3
1 changed files with 9 additions and 0 deletions
|
|
@ -7,9 +7,13 @@ func gear_id():
|
||||||
func continuous():
|
func continuous():
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
jeremy marked this conversation as resolved
Outdated
|
|||||||
|
func kill_ball(ball):
|
||||||
|
ball.queue_free()
|
||||||
|
|
||||||
func make_ball(player):
|
func make_ball(player):
|
||||||
var ball = RigidBody3D.new()
|
var ball = RigidBody3D.new()
|
||||||
var cs = CollisionShape3D.new()
|
var cs = CollisionShape3D.new()
|
||||||
|
var timer = Timer.new()
|
||||||
cs.shape = SphereShape3D.new()
|
cs.shape = SphereShape3D.new()
|
||||||
ball.name = "Ball"
|
ball.name = "Ball"
|
||||||
ball.mass = 4
|
ball.mass = 4
|
||||||
|
|
@ -20,11 +24,16 @@ func make_ball(player):
|
||||||
ball.set_collision_layer_value(1, false)
|
ball.set_collision_layer_value(1, false)
|
||||||
ball.set_collision_layer_value(3, true)
|
ball.set_collision_layer_value(3, true)
|
||||||
ball.set_collision_mask_value(3, true)
|
ball.set_collision_mask_value(3, true)
|
||||||
|
timer.one_shot = true
|
||||||
|
timer.autostart = true
|
||||||
|
timer.wait_time = 5
|
||||||
|
timer.timeout.connect(kill_ball.bind(ball))
|
||||||
|
|
||||||
var mesh = $GearMesh.duplicate()
|
var mesh = $GearMesh.duplicate()
|
||||||
mesh.position = Vector3.ZERO
|
mesh.position = Vector3.ZERO
|
||||||
ball.add_child(mesh)
|
ball.add_child(mesh)
|
||||||
ball.add_child(cs)
|
ball.add_child(cs)
|
||||||
|
ball.add_child(timer)
|
||||||
|
|
||||||
return ball
|
return ball
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
Add a blank line before this to separate it from the standard Gear functions