public static bool GetInputUp(DPadInput input) { if (input < 0 || input >= DPadInput.Count) { return(false); } return(inputUpList[(int)input]); }
/// <summary> /// Called every frame. /// </summary> private void Update() { // If our settings have changed, let's update our player data. if (GameSettings.PlayerMovementType != movementType) { movementType = GameSettings.PlayerMovementType; } DPadInput.Update(); if (isCarryingObject && objectBeingCarried != null) { Vector3 carryDestination = GetCarryObjectDestination(); objectBeingCarried.transform.position = Vector3.Lerp(objectBeingCarried.transform.position, carryDestination, Time.deltaTime * pickupMovementSmoothening); float rightJoystickHorizontalAxis = Input.GetAxis("RightJoystickHorizontal"); objectBeingCarried.transform.Rotate(Vector3.up * pickupRotationSpeed * Time.deltaTime * -rightJoystickHorizontalAxis, Space.World); // If we aren't pressing the pickup key, let's bail! // If we are pressing it at this point, we want to drop the item that we are holding. if (!DPadInput.Down) { return; } isCarryingObject = false; Rigidbody objectBeingCarriedRigidbody = objectBeingCarried.GetComponent <Rigidbody>(); objectBeingCarriedRigidbody.isKinematic = false; objectBeingCarriedRigidbody.velocity = vrCamera.transform.forward * objectDropThrowVelocity; // Reset the colour of the material just in case it was changed anywhere else. objectBeingCarried.GetComponent <MeshRenderer>().material.color = Color.white; objectBeingCarried = null; } else { // We only want to pickup an item when we press up on the Dpad. When it is NOT down, // let's bail out of this method. if (!DPadInput.Up) { return; } RaycastHit hit; if (!Physics.Raycast(vrCamera.transform.position, vrCamera.transform.forward, out hit)) { return; } // If the object we hit has no rigidbody or isn't on the pickup layer then there is nothing to do. if (hit.collider.attachedRigidbody == null || hit.transform.gameObject.layer != LayerMask.NameToLayer("Pickup")) { return; } // If the object we hit is out of range let's not pick it up. float distanceFromHit = Vector3.Distance(transform.position, hit.point); if (distanceFromHit > pickupRadius) { return; } isCarryingObject = true; objectBeingCarried = hit.transform.gameObject; hit.collider.attachedRigidbody.isKinematic = true; } }