Can you guys please help with my code. I have made this code which is made so that when the menu button on the VIVE is clicked, a new game object is spawned. For some reason, even though there are no errors, the code does not work. Please help me fix this code.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CreateBallOnPress : MonoBehaviour
{
public GameObject Ball;
public Vector3 BallValues;
private Valve.VR.EVRButtonId menuButton = Valve.VR.EVRButtonId.k_EButton_ApplicationMenu;
private SteamVR_Controller.Device controller { get { return SteamVR_Controller.Input((int)trackedObj.index); } }
private SteamVR_TrackedObject trackedObj;
void Update()
{
Vector3 BallPosition = new Vector3(BallValues.x, BallValues.y, BallValues.z);
Quaternion BallRotation = Quaternion.identity;
if (controller.GetPressDown(menuButton))
{
Instantiate(Ball, BallPosition, BallRotation);
}
}
}
↧