Files
godot-demo-projects/2d/finite_state_machine/player/bullet/bullet_spawner.gd
Hugo Locurcio aae565b34a [3.x] Enable physics interpolation in all demos that use physics (#1069)
This also improves visuals in the Voxel and Dynamic Split Screen demos,
and fixes splitscreen mode in the Platformer 2D demo.

Most demos (other than physics tests) have also had their physics FPS
increased to 120. This is done consistency with 4.x, but also for the
benefits it still provides when interpolation are enabled
(lower input lag, more stable simulation).
2024-11-22 16:57:10 +01:00

20 lines
359 B
GDScript

extends Node2D
var bullet = preload("Bullet.tscn")
func _unhandled_input(event):
if event.is_action_pressed("fire"):
fire()
func fire():
if not $CooldownTimer.is_stopped():
return
$CooldownTimer.start()
var new_bullet = bullet.instance()
new_bullet.position = global_position
new_bullet.direction = owner.look_direction
add_child(new_bullet)