Edit to add solution to the top: “[rotation] the rotation of the new game object, the rotation of the game object calling factory.create() is used by default, or if the value is nil”
I’m getting some very strange behaviour and I’m not sure if it’s a bug or a mistake on my end.
I have a spaceship that rotates to face the direction of the mouse cursor. As the player travels through space, I spawn “solar systems” in a grid pattern. It appears that the new solar systems that are spawned somehow inherit the euler.z property I set for the spaceship.
My collection proxy looks something like this:
The #script component of galaxy_player_ship sets euler.z as follows:
go.set(self.my_id, "euler.z", self.current_angle)
self.my_id is just a variable storing go.get_id() so I don’t have to call that over and over, the behaviour is the same if I replace it with go.get_id(). The rotation of the spaceship works as expected, and commenting out this line stops the problem I am having with the systems.
A lua module “system_generator” checks how far the spaceship has moved, and spawns new solar systems in response to movement. The solar systems are spawned like this:
local system_object = factory.create("system_factory#system_factory", game_utilities.universe_to_actual(system_details.universe_position + system_details.object_position))
I don’t think the problem lies in the game_utilities module, and checking the position/rotation of the system_factory game object reveals just the default position. I tried passing vmath.quat(0,0,0,0) as the
rotation argument when creating the object, but it appears to make no visual difference. Printing the rotation of the newly spawned object reveals 0,0,0,0 as expected, but visually it is still rotated. Without passing the argument, the printed rotation value is equal to that of the ship.
Since it is galaxy_player_ship that calls the system_generator module function to spawn systems, I thought perhaps the spawned objects somehow inherit the rotation from galaxy_player_ship. I moved the function call to an otherwise empty script, and turns out I was right. The objects now spawn correctly without rotation.
I guess I’m missing something? I suppose I’ve solved my problem but I’m in the early stages of designing this game and I’m really quite concerned that I am not understanding something fundamental here.