Jump to content
Doogie

Movement in VR

Recommended Posts

Hi everyone. New to Leadwerks, what a fantastic tool!

Question: has anyone developed a vr movement script that does not use teleporting? I have zero lua experience, trying to learn as I go.

Thanks in advance for any assistance!

Doogie

Share this post


Link to post

Thanks, I've already been looking at it. It's a bit complex looking currently, definitely need to develop more experience in lua. I was just wondering if anyone else had addressed the issue.

Share this post


Link to post

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. 

Share this post


Link to post
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!

Share this post


Link to post

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).

Share this post


Link to post

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.

Share this post


Link to post

I plan to write something up to give you an idea how to attach actors using the editor.

Share this post


Link to post
4 hours ago, reepblue said:

I plan to write something up to give you an idea how to attach actors using the editor.

That would be awesome. Thank You!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...