Quantcast
Viewing latest article 4
Browse Latest Browse All 102

Create GameObject On Click Not Working

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); } } }

Viewing latest article 4
Browse Latest Browse All 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>