Greetings,
I’ve got a very strange problem. I have a labyrinth generator that I’ve been creating. All the labyrinth logic is created in a C++ class, and the geometry is all added to the world through blueprints. I prefer to have the generation code in the Construction Script so I have visual feedback in the editor. This is not a problem.
My “Build Labyrinth” BP function calls my FCreateLabyrinth function from the C++ code which creates the data needed for the labyrinth build (all the individual tile data, picking the starting spot, picking the ending tile, and also generating the solution to the maze in an array from start to finish). This works great. I also have BP functions for placing the physical starting and ending portal meshes and particle systems. And, finally, I have a BP function that places the player at the starting point.
When I run all this from the OnBeginPlay in the Event Graph everything works fine and my player starts out on the starting tile with the correct rotation and positioning.
HOWEVER: if I move just my “Build Labyrinth” function to the Construction Script, my player spawns in at whatever direction he happened to be looking in the editor. (Even though my “Place Player at Start” function is still in the Event Graph in the OnBeginPlay event. There is nothing in my “Build Labyrinth” function that has anything to do with the player, aside from simply picking the Tile Index where the player start should eventually be. (But not actually PLACING any sort of player start there. Simply choosing the index number of the tile where the player should eventually start.) Build Labyrinth simply places the physical geometry like the floors, walls, lights, pillars and, optionally, ceilings). There is literally NO reason why the location of this function should have any bearing on the rotation of the player at the start of the maze.
So to recap:
With Build Labyrinth in the Construction Script, my player doesn’t rotate correctly, but is placed correctly from the OnBeginPlay.
With Build Labyrinth in the Event Graph, my player rotates and places correctly from the OnBeginPlay.
I’m at a loss.
This is the rotational code that I’m using:
(But without the “Teleport” bit set. That was just for testing purposes–has no effect on this.)