Set VR spawn rotation and position

Is there a way to force the player’s camera rotation in VR with blueprints? It seems that whatever direction I set the camera to be in the editor is the complete opposite in the headset. I want to always be facing the same direction at spawn regardless of wherever I may be facing in real life.

Thanks! :slight_smile:

When you spawn your pawn, reset your VR origin’s rotation to match the position of your pawn. This is the code I use in all my VR projects when the application loads.

Note: You would not want to force the rotation of a component which is recieving HMD rotation data. If the user themselves decides to face away from the desired position, you will have to create code to offset the desired rotation from the rotation of the pawn.

When the user teleports in VR and we want to force them face the chosen direction, I use the following calculation and call the “Teleport” function on the pawn.

Hi LoafMan. There could be a number of reasons why you are facing the wrong way, so I will give some suggestions.

  1. In the pawns class defaults, there are 3 fields which you need to make sure are set to false (unchecked).
    a. UseControllerRotationPitch = false
    b. UseControllerRotationYaw = false
    c. UseControllerRotationRoll = false

  2. Are you sure the pawn is getting set to the right rotation on initialise and how is the rotation getting set? Are you manually possesing the pawn on PostLogin (in the GameMode) and setting the rotation there, or is the pawn already in the world and you are autopossing it?

If you are using the HTC vive. During room setup you identify where your monitor is, Unreal will use this as the “forward facing direction”. When you initialise, the VR origin will track your position in the real world in realtion to this forward facing direction.

If your application uses a teleportation system which positions the user correctly after teleportation, you can try call that functionality when the pawn is created and “teleport” to the starting location. This isn’t a fix for the underlining issue, but should help you out if you are pushed for time.

Thank you for the reply, Alekann01! I do appreciate it! I created your blueprint system in my Motion Controller Pawn, but I am, unfortunately, still facing the wrong direction at spawn. :frowning:

I created the “Reset to Pawn Origin” function since I couldn’t find it by searching. I am very new to UE4, so I could be doing something wrong. I’m getting nervous since I am doing this for a project that has a rapidly approaching deadline. :\ Here is an image for reference.

Wow! I that was quick! Thank you for the prompt reply! :slight_smile:

  1. I checked in the pawns class defaults, and all of those items were set to off.

  2. I apologize, but I’m not sure I am savvy enough with UE4 to know what that means. Lol If I’m reading your question right, what I have is just the regular VR Template. So I didn’t change any of the settings. :slight_smile: As soon as I hit play (VR Preview) I am automatically spawned as the VR Pawn… I guess that’s how it would be said. :stuck_out_tongue:

Here is the crazy part, I had seen how to do this very thing in a UE4 Live Stream, but I can’t find the video which is so frustrating! I had it in my project, but it crashed and lost most of my Blueprint work, including the force set player spawn rotation. :frowning: So after checking my history to no avail, I thought I would ask here. :slight_smile: I really appreciate your help!!

No problem :slight_smile:

With regards to question 2, I am wondering how you are trying to set the pawns rotation.

This can be done a number of ways.

  1. Using a player start object which is manually placed in the world.
  2. Having the pawn itself already placed in the world with the set rotation.
  3. The pawn having it’s position and rotation manually set which is set when a player registers itself with the gamemode.

If you are using the Unreal, I would imagine you will be using one of the first two options.

In your pawn, could you print out on Begin Play the location and rotation of the pawn itself before any setup logic is called.
Should the location and rotation match what you are expecting then it’s an offset issue with the HMD, if is all 0, 0, 0 then it is the pawn itself which doesn’t know where it should be.

Glad you figured it out! :smiley:

To be honest, I tend to avoid using the VR template, it is very outdated and can be quite difficult to debug when things go wrong. When you get more expereince I highly recommend you have a go at building your own VR pawns. You will quickly gain a better understanding of what’s going on.

As for the teleport issue. That could be an array of problems. If you have just changed the tracking to “floor level”, make sure the appropiate calculation for that has been implemented.

Good luck with your project!

OH MAN!!! I just figured out how to make it work, and with one node too! :open_mouth:

There is an image to the setup below. :slight_smile:

I am however running into the issue now that after I spawn and then try to teleport, I am in the ground. :confused: I guess the issues never end. ;D

Thank you for all your help! :smiley: And yes, I will defiantly look into creating my own pawns in the near future! :slight_smile:

Thanks again!