oculus go movement
Hello guys,
im new unity and with C#. Ive tried to implement a movement with my oculus go and its working. I can move forward and faster. but i cant move backward. Do you know what mistake ive done. Here is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Walking : MonoBehaviour {
float speed = 2.0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
var position = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTrackedRemote);
if (OVRInput.Get(OVRInput.Button.PrimaryTouchpad)) // nach vorne gehe wenn Touchpad drückt
{
Vector2 primaryTouchpad = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
if (primaryTouchpad.y > 0f)
{
this.transform.parent.position += this.transform.parent.forward * Time.deltaTime * speed;
Debug.Log("Go forward");
}
if(primaryTouchpad.y < 0f)
{
this.transform.parent.position -= (this.transform.parent.position - this.transform.parent.forward) * Time.deltaTime * speed;
Debug.Log("Go Backward");
}
}
else if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
{
float faster = 3.0f;
this.transform.parent.position += this.transform.parent.forward * Time.deltaTime * (speed + faster);
Debug.Log("Go Faster");
}
}
}
Comment