I want to create objects in front of the player with a certain distance, in order to avoid any immediate contact with the player. So first, I get the vector position and overall direction of the player to which the player is addressing:
var player_position = player.transform.origin var player_forward_vector = player.global_transform.basis.z
And then give an extra 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 start the game, it seems at first that the work works, however, when I rotate the player, the object always created in the same position, not in front of what I am looking at.
Here is the video to demonstrate:
Why are not objects created in front of the player, but do they keep spawns in the same place? Any advice will appreciate it a lot.