void Update() { if (DEBUG) { TestToast(); } if (!_isLoaded && !UnityEngine.XR.XRSettings.isDeviceActive) { _isLoaded = true; GameObject.Destroy(GameObject.Find("CustomHandLeft")); GameBarrel.Destroy(GameObject.Find("CustomHandRight").GetComponent <MeshRenderer>()); } }
void OnTriggerEnter(Collider col) { int random = UnityEngine.Random.Range(0, 100); if (random < PERCENT_SHORTCUT) { GameBarrel script = col.gameObject.GetComponent <GameBarrel>(); if (script != null) { script.PerformShortcut(); } } }
private void DoSpawn() { GameObject instance = Instantiate(Prefab, SpawnPosition, Quaternion.Euler(Rotation.x, Rotation.y, Rotation.z)); instance.name = "barrel"; Rigidbody rigidBody = instance.GetComponent <Rigidbody>(); rigidBody.velocity = new Vector3(0, 0, InitialBarrelVelocity); GameBarrel barrel = instance.GetComponent <GameBarrel>(); barrel.OnShouldDestroy += OnShouldDestroy; _barrels.Add(instance); }