I want to create objects in front of player with some distance, so that prevents hit with player immediately. So first, I get the global player position and direction vector which player towards:
var player_position = player.transform.origin
var player_forward_vector = player.global_transform.basis.z
And then give additional distance:
var spawn_position = player_position
spawn_position.z -= player_forward_vector.z + 100
And then set the position:
var asteroid_instance = asteroid_scene.instance()
asteroid_instance.transform.origin = spawn_position
When I run the game, first it seems work, however when I rotated the player, still object spawned same position, not in front of where I'm looking at.
Here's the video to demonstrate:
Why object doesn't created in front of player, instead keep spawns in same location? Any advice will very appreciate it.