Created
March 1, 2025 19:44
-
-
Save lamarmarshall/1eeeb3b60f21e14514914b0a4e153481 to your computer and use it in GitHub Desktop.
godot 4, aim, shoot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node3D | |
@export var projectile: PackedScene | |
@onready var turret_top: MeshInstance3D = $TurretBase/TurretTop | |
var enemy_path: Path3D | |
func _physics_process(delta: float) -> void: | |
var enemy = enemy_path.get_children().back() | |
look_at(enemy.global_position, Vector3.UP, true) | |
func shoot(start_position: Vector3) -> void: | |
var shot = projectile.instantiate() | |
add_child(shot) | |
shot.global_position = start_position | |
shot.direction = basis.z | |
func _on_timer_timeout() -> void: | |
shoot(turret_top.global_position) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment