smooth Movement script for Player prefab in Steam VR using Oculus Rift touch controllers?
Hello Guys, Could anyone please suggest or provide an approach for adding scripts for Player Prefab object in SteamVR utility for Rift Touch controllers? What to add for this player object to move on Terrain field. When i tested it with the below transition of player, movement is going through y axis at 0 . I have gone through FPS controller prefab available in the SteamVR plug in and What component of player prefab script needs to be changed/updated to get the player movement smooth. Here is the script, I can able to access Hand control and got into movement of player by transitioning the position with respect to speed variable.
using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using UnityEngine.AI; using UnityEngine; using UnityEngine.Events; using Valve.VR.InteractionSystem;
public class CustomPlayer : MonoBehaviour {
public Hand leftHand; public Hand rightHand;
void Start() { player = Player.instance; }
bool isLeftTriggerPressed() { return this.leftHand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger); }
bool isRightJoystickHeadingLeft() {
//Debug.Log(" left
movement of joystick"+ this.rightHand.controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x);
return this.rightHand.controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x<0 ;
}
bool isRightJoystickHeadingRight()
{
return this.rightHand.controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).x>0 ;
}
bool isRightJoystickHeadingDown() {
return this.rightHand.controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y<0; }
bool isRightJoystickHeadingForward() {
return this.rightHand.controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0).y>0 ;
}
private void FixedUpdate() { float step = speed * Time.deltaTime; Vector3 back = new Vector3 (0, 0 - 2);
if(isRightJoystickHeadingDown()){
//Debug.Log (" joystick down");
this.player.transform.Translate(Vector3.back* step); }
if(isRightJoystickHeadingLeft()){
//Debug.Log (" joystick left");
this.player.transform.Translate(Vector3.left* step);
}
if(isRightJoystickHeadingRight()){
//Debug.Log (" joystick right");
this.player.transform.Translate(Vector3.right* step);
}
if(isRightJoystickHeadingForward()){
//Debug.Log (" joystick forward");
this.player.transform.Translate(Vector3.forward* step); } }
Blockquote
When user moves thumbstic( Right Hand Jostic) according to direction like forward, back, left and right methods are calling. This movement looks not just fine. Any suggesstions on this transition smoothness would be great help full for my first application. I wanted to transform player transition irrespective of the camera and smooth navigation of player movement with thumbstic movement of Rift controller. I appreciate for your help prior.
Answer by buddy_shiva · Aug 17, 2017 at 07:08 PM
Can anyone suggest me on this issue please? @crazyKnight @duck . I am just seeking help/guidance fromyou by tagging . Please don't mind