Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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!

    -Marc

    #2
    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.

    Comment


      #3
      Click image for larger version

Name:	spawning player.png
Views:	1
Size:	52.3 KB
ID:	1098053
      This is what I'm currently using.

      Comment


        #4
        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.

        Comment


          #5
          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.

          Comment


            #6
            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.
            Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

            My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
            (Including 100+ Pages Multiplayer Network Compendium to get you started.)

            Comment


              #7
              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():

              Click image for larger version

Name:	SetControlRotation.JPG
Views:	1
Size:	25.7 KB
ID:	1098126
              • Follow me on twitter
              • Visit our website traverse.world
              • Checkout our game's forum thread

              Comment


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

                Click image for larger version

Name:	setrotation.jpg
Views:	2
Size:	247.8 KB
ID:	1098283

                Comment


                  #9
                  what about overwriting functions
                  Code:
                  ChoosePlayerStart
                  or
                  Code:
                  FindplayerStart
                  in game mode?

                  Comment

                  Working...
                  X