Jump to content

Movement in VR


Doogie
 Share

Recommended Posts

I've done some locomotion experiments in C++. Just set the VR tracking space to Seated and move the character controller with the analog sticks. 

Time is really tight during the week, but I can try to write you something in Lua quick on the weekend if you'd like. 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

On 12/12/2019 at 6:09 PM, reepblue said:

I've done some locomotion experiments in C++. Just set the VR tracking space to Seated and move the character controller with the analog sticks. 

Time is really tight during the week, but I can try to write you something in Lua quick on the weekend if you'd like. 

@reepblue I don't want to impose, but if you do find the time, that would be amazing!

Link to comment
Share on other sites

TL;DR: You can do a locomotion VR Player, but you need the C++ libraries due to one member being exposed. I didn't write any lua code, the code below is all C++; which can be converted to the lua syntax easily.

The good news is I've done exactly what you have in mind. The bad news is that It's not possible in Lua due to one member not being exposed which is:

static Quat headsetrotation;

You need that member to apply the character's controller's rotation based on where the player is looking in the real world. Other than that,the only other tricky part is updating the VR offset with the player's location. We have CenterTracking called when a button is pressed to correct the center as we use Seated VR for this implementation (Seems the A and B buttons with the Index don't work in 4.6)

		if (VR::GetControllerButtonHit(VR::Left, VR::TriggerButton))
		{
			VR::CenterTracking();
		}

		Vec3 playerpos = GetEntity()->GetPosition();
		auto cameraposition = Vec3(playerpos.x, playerpos.y, playerpos.z);
		VR::SetOffset(cameraposition + Vec3(0, m_flEyeHeight, 0));
		m_pCamera->SetPosition(VR::GetOffset());

Then you move the character controller with this:

		playerMovement.x = Math::Clamp(VR::GetControllerAxis(VR::Left, VR::TouchpadAxis).x, -1.0f, 1.0f) * m_flMoveSpeed;
		playerMovement.z = Math::Clamp(VR::GetControllerAxis(VR::Left, VR::TouchpadAxis).y, -1.0f, 1.0f) * m_flMoveSpeed;

I only did this in 4.6. I'm tempted to try this with the 4.7 beta as Seated VR is said to be fixed (And hopefully buttons on the Index work).

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

  • 4 months later...

Hi Guys,

If you are stuck I can share my implementation of free movement in VR I wrote in LUA (pm me).

reepblue -> Sorry for a noob question, but Im still looking through forums and can't fiind an aswer: How can I use c++ in player scirpts? Engine only allows me to attach lua script to enity, I have the project opened in Visual Studio as well. I have seen some post about people setting up cpp project with loosing lua ability, its still very confusing for me. Any help would be appreciated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...