void Update() { if (!isWatched) { return; } // Set up cursor mode if (interactiveObject.CanInteract()) { if (GvrPointerInputModule.CurrentRaycastResult.distance <= maxDistance) { // Set cursor to can interact VRCursor.SetState(VRCursor.CursorState.CAN_INTERACT); } else { // Set cursor to too far to interact VRCursor.SetState(VRCursor.CursorState.TOO_FAR); } } else { // Set cursor to can't interact VRCursor.SetState(VRCursor.CursorState.CANNOT_INTERACT); } }
public override void Interact() { fire.SetActive(true); IsLit = true; Destroy(GetComponent <InteractiveObjectController>()); VRCursor.SetState(VRCursor.CursorState.NEUTRAL); }
protected void Update() { if (!isEnabled) { if (isWatched) { VRCursor.SetState(VRCursor.CursorState.NEUTRAL); } targetCircleController.EnableRenderer(false); return; } if (IsJumpingStatic) { VRCursor.SetState(VRCursor.CursorState.NEUTRAL); } // Continue jumping if already in progress if (isJumping) { Jump(); } else if (isWatched) { if (!IsJumpingStatic) { targetCircleController.EnableRenderer(true); } UpdateCircleTransform(); UpdateCanJump(); UpdateCursor(); } }
public override void Interact() { isMoving = true; isOpen = true; Destroy(GetComponent <InteractiveObjectController>()); VRCursor.SetState(VRCursor.CursorState.NEUTRAL); InventoryController.RemoveItem("Key"); }
public override void Interact() { InventoryController.RemoveItem(itemName); pickupable.SetEnabled(true); keySphere.GetComponent <InteractiveObjectController>().isWatched = false; pickupable.isPickedUp = false; isEmpty = false; GetComponent <InteractiveObjectController>().enabled = false; VRCursor.SetState(VRCursor.CursorState.NEUTRAL); }
public override void Interact() { if (EquipmentController.CurrentItem == EquipmentController.EquipableItem.TORCH) { IsOnFire = true; fire.SetActive(true); VRCursor.SetState(VRCursor.CursorState.NEUTRAL); Destroy(GetComponent <InteractiveObjectController>()); //Destroy(gameObject, burnTime); } }
virtual protected void UpdateCursor() { if (canJump) { VRCursor.SetState(VRCursor.CursorState.CAN_STEP); targetCircleController.SetColor(canJumpColor); } else { VRCursor.SetState(VRCursor.CursorState.CANNOT_STEP); targetCircleController.SetColor(cannotJumpColor); } }
new void Update() { // Check if already jumping globally if (IsJumpingStatic && !isJumping) { return; } // If already jumping, continue if (isJumping) { Jump(); return; } // Check if colliding at all RaycastResult raycastResult = GvrPointerInputModule.CurrentRaycastResult; GameObject lookAtObject = raycastResult.gameObject; if (lookAtObject == null) { targetCircleController.EnableRenderer(false); return; } // Check that not colliding with floor if (lookAtObject.GetComponentInChildren <FloorController>() != null || lookAtObject.GetComponentInParent <FloorController>() != null) { return; } // Temporarily disable circle renderer targetCircleController.EnableRenderer(false); // Check that colliding with walls if needed if (onlyWalls && lookAtObject.layer != wallLayerMask) { return; } // Check that not colliding with interactive object if (lookAtObject.GetComponentInParent <InteractiveObjectController>() != null) { return; } // Check that locomotion is enabled if (!isEnabled) { VRCursor.SetState(VRCursor.CursorState.NEUTRAL); return; } // Step back from hit position Vector3 hitPos = raycastResult.worldPosition; Vector3 projNorm = new Vector3(raycastResult.worldNormal.x, 0, raycastResult.worldNormal.z); projNorm.Normalize(); float stepbackDist; switch (stepBackDirection) { case StepBackDirection.LINE_OF_SIGHT: // Step back along player line of sight xz-plane projection Vector3 projLOS = new Vector3(hitPos.x - playerTransform.position.x, 0, hitPos.z - playerTransform.position.z); projLOS.Normalize(); stepbackDist = (playerRadius + stepBackThreshold) / Vector3.Dot(projNorm, -projLOS); jumpTarget = raycastResult.worldPosition - projLOS * stepbackDist; break; case StepBackDirection.NORMAL: // Step back along object normal xz-plane projection stepbackDist = playerRadius + stepBackThreshold; jumpTarget = raycastResult.worldPosition + projNorm * stepbackDist; break; } // Find floor beneath RaycastHit floorHit = new RaycastHit(); bool isHitFloor = Physics.Raycast(jumpTarget, -Vector3.up, out floorHit, playerHeight, -1 ^ floorLayerMask); if (!isHitFloor) { return; } FloorController floorController = floorHit.collider.gameObject.GetComponentInParent <FloorController>(); if (floorController == null) { floorController = floorHit.collider.gameObject.GetComponentInChildren <FloorController>(); if (floorController == null) { Debug.Log("U F****d up, m8"); return; } } onFloorPosition = floorHit.point; floorTransform = floorHit.collider.gameObject.transform; // Check if floor controller is enabled if (!floorController.enabled) { return; } // Check that colliding at acceptable height float hitHeight = hitPos.y - floorHit.point.y; if (hitHeight < 0 || hitHeight > playerHeight) { return; } // Adjust jumpTarget y-coordinate jumpTarget.y = floorHit.point.y + playerEyeHeight; UpdateCanJump(); UpdateCursor(); // Check if trigger down if (canJump && cursor.TriggerDown) { Jump(false); return; } // Activate circle on floor UpdateCircleTransform(); targetCircleController.EnableRenderer(true); }