09-20-2020 03:07 PM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Oculus.Platform;
using Oculus.Platform.Models;
public class PlayerController : SocialPlatformManager
{
// Appears in the Inspector view from where you can set the speed
public float speed = 500;
// Rigidbody variable to hold the player ball's rigidbody instance
private Rigidbody rb;
// Secondary camera to debug and view the whole scene from above
public Camera spyCamera;
// The OVRCameraRig for the main player so we can disable it
private GameObject cameraRig;
private bool showUI = true;
public override void Awake()
{
base.Awake();
cameraRig = localPlayerHead.gameObject;
}
// Use this for initialization
public override void Start()
{
base.Start();
spyCamera.enabled = false;
// Assigns the player ball's rigidbody instance to the variable
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
public override void Update()
{
base.Update();
OVRInput.Update();
Vector2 x_y = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
float moveHorizontal = 0.5f; //x_y.x; // 100.0f; //
float moveVertical = 0.5f; //x_y.y; // 100.0f; //
//float moveHorizontal = Input.GetAxis("Horizontal");
//float moveVertical = Input.GetAxis("Vertical");
// Vector3 variable, movement, holds 3D positions of the player ball in form of X, Y, and Z axes in the space.
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
// Adds force to the player ball to move around.
rb.AddForce(movement * speed * Time.deltaTime);
}
void ToggleCamera()
{
spyCamera.enabled = !spyCamera.enabled;
localAvatar.ShowThirdPerson = !localAvatar.ShowThirdPerson;
cameraRig.SetActive(!cameraRig.activeSelf);
}
void ToggleUI()
{
showUI = !showUI;
helpPanel.SetActive(showUI);
localAvatar.ShowLeftController(showUI);
}
}
When I build and run the app on my Quest, I see the ball and box, but the controller inputs don't make anything move, and nothing moves even if I hardcode moveHorizontal and moveVertical (as above). Is there any other step I need to take to get updating to work?09-22-2020 12:29 PM
09-22-2020 03:12 PM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Oculus.Platform;
using Oculus.Platform.Models;
public class PlayerController : MonoBehaviour
{
// Appears in the Inspector view from where you can set the speed
public float speed = 500;
// Rigidbody variable to hold the player ball's rigidbody instance
private Rigidbody rb;
// Secondary camera to debug and view the whole scene from above
public Camera spyCamera;
// The OVRCameraRig for the main player so we can disable it
private GameObject cameraRig;
//private bool showUI = true;
private GameObject localPlayerHead;
void Awake()
{
localPlayerHead = this.transform.Find("OVRCameraRig/TrackingSpace/CenterEyeAnchor").gameObject;
cameraRig = localPlayerHead.gameObject;
}
// Use this for initialization
void Start()
{
spyCamera.enabled = false;
// Assigns the player ball's rigidbody instance to the variable
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
private void Update()
{
OVRInput.Update();
Vector2 x_y = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
float moveHorizontal = x_y.x; // 100.0f; //0.5f; //
float moveVertical = x_y.y; // 100.0f; //0.5f; //
// Vector3 variable, movement, holds 3D positions of the player ball in form of X, Y, and Z axes in the space.
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
// Adds force to the player ball to move around.
rb.AddForce(movement * speed * Time.deltaTime);
}
}