I am working on a project that allows for a user to evaluate a building using virtual reality with an Oculus Rift. I’m trying to figure out a way to program a button click that will allow me to change levels so the character will have different viewpoints to evaluate the space. The problem that I have is I’m not sure how to program this button click and due to the nature of the study, I can’t use a box trigger or something of the sort because I cannot have the player physically move around the model due to the possibility of motion sickness. Any help on this would be greatly appreciated as my Unreal Experience is quite limited. Thanks!
Hello. So basically you want to move the player from place to place through a sequence of view points right?
The easiest way to do it is to create a simple Blueprint actor, let’s call it BP_TargetPoint, with just a Scene Component in it and a with single variable editable externally, let’s call it Next Target Point, which should be a Reference to BP_TargetPoint. You can place as many as those in your level and link one to the other, through the Next Target Point variable, to form a sequence of view points to move the player through. Make sure you place them exactly on the floor so when the player is moved you don’t change its height (asssuming your tracking origin is at Floor Level).
Then in your Level Blueprint (even if it would be better to do it inside the VR Pawn) you create a new variable of type Reference to BP_TargetPoint. Call it Current Target Point. Assign to it the first Target Point in your level.
Now still inside the Level Blueprint, create an event for the key which triggers the movement to the next Target Point. Right click in the Event Graph, search for Keyboard events and choose for example “N” as in next. Drag out of its execution pin and search for SetWorldLocation. Now you need to get a reference to the VR Pawn and connect it as Target to this function. Right click and look for Get Player Controller. Drag out of its output and search for Get Controlled Pawn. Now we have a reference to the VR Pawn to connected to the Target input of the SetWorldLocation function.
Next we need a reference to the location to move to. This is easy. Drag the Current Target Point variable to the Event Graph and select Get. Drag out of its output and search for Get Next Target Point. Drag out of Next Target Point and search for GetWorldLocation. This is the value to feed into the New Location pin of SetWorldLocation. Check the Teleport option in it.
Very last thing. Drag out of the execution pin of SetWorldLocation and look for Set Current Target Point. Assign to it the output of the Get Next Target point as used above. This will update the Current Target Point variable with the new location we are in, ready for the next move.
That’s it. Now when you Play and press “N” on the keyboard your VRPawn will move from location to location. You can also link the last one to the first one to make a round trip.
Hope this helps!