Barbarian Blaster - Damaging Enemies Lesson

So I followed the lesson and changing from basis.z to global_transform.basis.z did nothing to help the shot being off.

  1. extends Node3D
  • @export var projectile: PackedScene
  • var enemy_path: Path3D
  • @onready var turret_top: MeshInstance3D = $TurretBase/TurretTop
  • func _physics_process(_delta: float) → void:
  1. var enemy = enemy_path.get_children().back()
  2. look_at(enemy.global_position, Vector3.UP, true)
  • func _on_shot_timer_timeout() → void:
  1. var shot = projectile.instantiate()
  2. add_child(shot)
  3. shot.global_position = turret_top.global_position
  4. shot.direction = global_transform.basis.z

just a heads up using 4.2.1

saw another post about this same lesson but instead of using the basis they used direction_to tried that shot is still off.

git repo is here https://github.com/matruim/godot-games/tree/main/BarbarianBlaster

I figured it out. I had a mistake in the projectile and it was translating instead of setting the global position.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms