// Update is called once per frame private void Update() { Vector3 direction = transform.TransformDirection(Vector3.forward); // Looking direction. Vector3 origin = transform.position; // Position of the player's body. Ray ray = new Ray(origin, direction); // Creates a ray starting at origin along direction. RaycastHit hitInfo; // Structure used to get information back from a raycast. // If the player is facing some object. if (Physics.Raycast(ray, out hitInfo, interactionRange)) { // If the player is not crouched or flying. if (!controller.isCrouched && controller.Grounded) { // If the player is not vaulting something. if (!controller.isClimbing && controller.canVault) { // If you press the jump button or the player are running. if ((Input.GetKeyDown(KeyCode.Space) && controller.GetInput().y > 0) || controller.moveState == MoveState.Running) { // Get the information from the object forward. ParkourTrigger p = hitInfo.collider.GetComponent <ParkourTrigger>(); if (p != null) { // If the object contains the ParkourTrigger component, takes the information for the vault. StartCoroutine(Vault(p.speed, p.climb, p.endPosition)); } } } } } }
private void TriggerParkour(ParkourTrigger trigger) { triggerBuffer.Add(trigger); }