mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 23:10:08 +01:00
This makes uses of the new built-in 2D physics interpolation added in 4.3. For 3D demos, a separate PR requiring `master` will be made later.
19 lines
391 B
GDScript
19 lines
391 B
GDScript
extends Node2D
|
|
|
|
var bullet := preload("Bullet.tscn")
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("fire"):
|
|
fire()
|
|
|
|
|
|
func fire() -> void:
|
|
if not $CooldownTimer.is_stopped():
|
|
return
|
|
|
|
$CooldownTimer.start()
|
|
var new_bullet := bullet.instantiate()
|
|
new_bullet.position = global_position
|
|
new_bullet.direction = owner.look_direction
|
|
add_child(new_bullet)
|