Jump to content

thumbstick turning in VR


ga1pi2ga
 Share

Recommended Posts

has anyone figured out thumb stick turning in vr? ,i have tried it but keep on getting a error that i do not know how to fix (i am using VRplayer lua the only extra code is here:)

	--teleporting feedback
	if VR:GetControllerButtonDown(VR.Right,VR.AButton) then
	VR:TriggerHapticPulse(VR.Right,50)
	end
	--player turning right
	if VR:GetControllerAxis(VR.Right,VR.TouchpadAxis).x > 0.15 then
		VR:TriggerHapticPulse(VR.Right,20)
		player:turn(0,45,0)
	end
	--player turning left
	if VR:GetControllerAxis(VR.Right,VR.TouchpadAxis).x < -0.15 then
		VR:TriggerHapticPulse(VR.Left,20)
		player:turn(0,-45,0)
	end

image.thumb.png.329b70b14665a6ed86d12c905d6ac04e.png

image.thumb.png.a9f39a7897a9c034678780d5d80a6162.png

Link to comment
Share on other sites

Ah Okay.

Turning the world around the VR player is only supported if you opt into the beta branch on Steam.

This command offsets the position:
https://www.leadwerks.com/learn?page=API-Reference_Object_VR_SetOffset

If you call VR:SetOffset(position, rotation) or VR:SetOffset(x,y,z,pitch,roll,yaw) then it will turn the world around the player.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

okay now i just cannot teleport outside of a small area otherwise the rotation works fine

function Script:UpdateWorld()

	VR:SetOffset(0,0,0,0,avr,0)

	--teleporting feedback
	if VR:GetControllerButtonDown(VR.Right,VR.AButton) then
	VR:TriggerHapticPulse(VR.Right,50)
	end
	--player turning right
	if VR:GetControllerAxis(VR.Right,VR.TouchpadAxis).x > 0.15 then
		VR:TriggerHapticPulse(VR.Right,20)
		avr=avr+5
	end
	--player turning left
	if VR:GetControllerAxis(VR.Right,VR.TouchpadAxis).x < -0.15 then
		VR:TriggerHapticPulse(VR.Left,20)
		avr=avr-5
	end

 

Link to comment
Share on other sites

If you are using the built-in teleport locomotion, let's see...this is at line 299 of VRPlayer.lua:

	--Update offset position
	local pos = VR:GetOffset()
	local d = self.targetoffset:DistanceToPoint(pos)
	local speed = 2.0
	if speed>d then speed=d end
	pos = pos + (self.targetoffset - pos):Normalize() * speed
	VR:SetOffset(pos)

So you would want to add the rotation to that call of the VR:SetOffset() command:

VR:SetOffset(pos,rot)

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

please ignore the previous post figured it out

--Update offset position
	local pos = VR:GetOffset()
	local d = self.targetoffset:DistanceToPoint(pos)
	local speed = 2.0
	if speed>d then speed=d end
	pos = pos + (self.targetoffset - pos):Normalize() * speed
	local arot = Vec3(0,avr,0) --avr is addon rotation
	VR:SetOffset(pos,arot)

 

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

If I want to use smooth locomotion and not teleport, how would I call this upon joystick movement? I know it involves VR:SetOffset or VR:GetOffset. Further, I can enter the VR world, but teleport nor locomotion work at all.  I can walk around the world physically.  How do I activate teleport and locomotion with the joystick controllers?

Mike

MSI Dominator Laptop - Core i7 - 8 cores / 3ghz / 32gb RAM / Nvidia 980 GTX with 16gb vram / SSD drives

MSI Dominator Laptop - Core i7 - 8 cores / 3ghz / 32gb RAM / Nvidia 1060 GTX with 8gb vram / SSD drives

Alienware Laptop - Core i7 - 8 cores / 3ghz / 32gb RAM / Nvidia 1070 Ti with 16gb vram / SSD drives

My Patreon page: https://www.patreon.com/michaelfelkercomposer

My music for sale: https://www.tgcstore.net/category/513?format=all&amp;perpage=30&amp;textures=undefined&amp;price=all&amp;order=default&amp;artists[]=87213

Custom synths and sounds - http://www.supersynths.com

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