Jr_Dev
1
Godot Version
4.3
Hey guys, I’m making an enemy that shoots projectiles at the player.
The projectile targeting is simple,
func _ready():
var look = target.global_position
look_at(look)
This works normally, but when instanced they use the origin as a base point.
tassup
2
Do you mean that they don’t find the target and fly to the wrong place,
or that they appear in the wrong place when instanced?
Jr_Dev
3
They appear in the correct position but they fly to the wrong place
tassup
4
How do you set the target? Maybe there’s something wrong there. Any warnings in the console? You could try printing the name of the target:
func _ready():
var look = target.global_position
look_at(look)
print(target.name)
Jr_Dev
5
I set the target using
@onready var target = $"../Player1"
tassup
6
Could this be the same problem: Help with look_at() function - #5 by Fryker
If that’s it, you can just rotate after look_at:
func _ready():
var look = target.global_position
look_at(look) # x-axis is pointing at target
rotate(PI/2) # Now y-axis is pointing at target