public void ApplyPlayersForce(ScreenSegment segment) { foreach (GameObject gameObject in spawnedObjects[segment]) { gameObject.GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, 14)); } }
private void FixedUpdate() { fixedUpdateModuloCounter = (fixedUpdateModuloCounter + 1) % 50; if (fixedUpdateModuloCounter == 0) { ImportedItem item = PickItem(); ScreenSegment segment = PickScreenSegment(); ThrowItem(item, segment); } }
private void Start() { // VRTK input here var interact = GetComponent <VRTK_InteractableObject>(); interact.InteractableObjectTouched += OnTouch; interact.InteractableObjectUntouched += OnUnTouch; interact.InteractableObjectUsed += OnUse; Segment = GetComponentInChildren <ScreenSegment>(); }
public void Land(GameObject gameObject) { ScreenSegment segment = inverseDictionary[gameObject]; if (segment == ScreenSegment.TOP_LEFT) { inverseDictionary[gameObject] = ScreenSegment.BOTTOM_LEFT; spawnedObjects[ScreenSegment.BOTTOM_LEFT].Add(gameObject); spawnedObjects[ScreenSegment.TOP_LEFT].Remove(gameObject); } else if (segment == ScreenSegment.TOP_RIGHT) { inverseDictionary[gameObject] = ScreenSegment.BOTTOM_RIGHT; spawnedObjects[ScreenSegment.BOTTOM_RIGHT].Add(gameObject); spawnedObjects[ScreenSegment.TOP_RIGHT].Remove(gameObject); } }
private void ThrowItem(ImportedItem item, ScreenSegment segment) { GameObject spawnedObject = Instantiate(item.gameObject, spawnPoint, transform.rotation); broker.Register(segment, spawnedObject); ItemProperties properties = item.itemProperties; Rigidbody rigidBody = spawnedObject.GetComponent <Rigidbody>(); rigidBody.mass = properties.mass; Vector3 side; Vector3 up; Vector3 towards; switch (segment) { case ScreenSegment.TOP_LEFT: side = properties.forceSide * Vector3.left; up = properties.forceUpHigh * Vector3.up; towards = properties.forceBack * Vector3.back; break; case ScreenSegment.BOTTOM_LEFT: side = properties.forceSide * Vector3.left; up = properties.forceUpLow * Vector3.up; towards = properties.forceBack * Vector3.back; break; case ScreenSegment.TOP_RIGHT: side = properties.forceSide * Vector3.right; up = properties.forceUpHigh * Vector3.up; towards = properties.forceBack * Vector3.back; break; default: side = properties.forceSide * Vector3.right; up = properties.forceUpLow * Vector3.up; towards = properties.forceBack * Vector3.back; break; } rigidBody.AddForce(side + up + towards); }
public void Register(ScreenSegment segment, GameObject gameObject) { spawnedObjects[segment].Add(gameObject); inverseDictionary[gameObject] = segment; }