Need to set a random player start spot in generated single player level

Greetings. I’m generating my level through a C++ class that I’ve created, but doing all the actual level spawning through Blueprints.

I’ve got my level geometry created and spawning just fine (I’m doing this in the construction script of my LevelGenerator class.)

Now I need to grab the center of a specific “tile” I designate (not a problem) and set that to be the player spawn spot. I’m able to use a “Get Player Pawn” with a SetActorLocation attached to it, but I also need to set the view rotation on that pawn to one of four different directions based on the directions available. Getting the values I need isn’t a problem, but actually setting the player’s rotation still eludes me for some reason. My usual smoke breaks aren’t giving me any breakthroughs. Is there a better, more preferred way to do this? Tried searching for the answers I needed, but didn’t quite come up with anything that worked for me.

Thanks!

I should add that an anomaly I’m seeing using this method (and the fact that I’ve changed everything to be inside of an EventBeginPlay) is that for some starting spots I start on the floor, but other starting spots I drop down about a foot or two. Not really sure what’s going on there.

spawning player.png
This is what I’m currently using.

Well, the first thing I am seeing is that you are not setting the Rotation at all. Nothing is plugged into the Rotation node, and they are all set to 0.0. You may also try turning on the Sweep boolean.

Yes, I realize that. The SetActorLocation only allows for a location vector. There’s also a SetActorLocationAndRotation, which I’ve tried using and plugging a rotator into it, but that doesn’t even change my location, let alone rotation. Also, if I come off of this with a SetActorRotation, it still doesn’t change the rotation. I’m looking for either the next step, or something that will work better because this definitely doesn’t do everything I need.

Thanks.

Well, you just need to call “SetActorRotation” OR “SetControlRotation” (on the Controller) based on what exactly you are trying.

You can also (for the PlayerPawn, not the Controller) use “SetTransform”.

You ALSO don’t need the “Make Transform” node if you just use the Location anyway. Rightclick the “New Location” vector AFTER you disconnected the current
Vector and select “Split Struct”. Then you can directly plugin X and Y.

For the Rotation it would be nice knowing if the Character is controlled by the Control Rotation and i would like to see how you are trying to set the Rotation atm.

SetActorRotation() will work, as long as Character Rotation is not overriden due to bUseControllerRotation (Pitch/Yaw/Roll) flags. In that case, you’ll need SetControlRotation():

c99352dc8a6a2b5bb59064e552f665f7b245b9a9.jpeg

Thanks! Yeah, I kinda stumbled onto the answer before making it back here to see what you posted. :slight_smile:
For anyone else who may want a “complete solution” this is what I’m doing in my function:

what about overwriting functions


ChoosePlayerStart

or


FindplayerStart

in game mode?