// Update is called once per frame void Update() { if (Input.GetButton("Fire3") /*GetKeyDown(KeyCode.Space)*/ == true) { Collider2D[] interactInRange = Physics2D.OverlapBoxAll(transform.position, Vector2.one, 0, LayerMask.GetMask("Interact")); if (interactInRange.Length > 0) { for (int i = 0; i < interactInRange.Length; i++) { Interactible myInteract = interactInRange[i].GetComponent <Interactible>(); if (myInteract != null) { //myInteract.StartExecute(this); Debug.Log("Get GameObject = " + interactInRange[i].gameObject.name); } } Debug.Log("Fin"); } } else if (Input.GetButtonUp("Fire3")) { Collider2D[] interactInRange = Physics2D.OverlapBoxAll(transform.position, Vector2.one, 0, LayerMask.GetMask("Interact")); if (interactInRange.Length > 0) { for (int i = 0; i < interactInRange.Length; i++) { Interactible myInteract = interactInRange[i].GetComponent <Interactible>(); if (myInteract != null) { myInteract.EndExecute(); } } } } }
private void ProcessInput() { // Process interact if (interacting == true) { Debug.Log("Dans interact"); Collider2D[] interactInRange = Physics2D.OverlapBoxAll(transform.position, new Vector2(0.5f, 0.5f), 0, LayerMask.GetMask("Interact")); Debug.Log("On a " + interactInRange.Length.ToString() + " interactible a porter"); if (interactInRange.Length > 0) { for (int i = 0; i < interactInRange.Length; i++) { Interactible myInteract = interactInRange[i].GetComponent <Interactible>(); if (myInteract != null) { myInteract.StartExecute(this); disableInteracting = true; Debug.Log("Get GameObject = " + interactInRange[i].gameObject.name); break; } } return; } } else if (disableInteracting == true) { disableInteracting = false; Collider2D[] interactInRange = Physics2D.OverlapBoxAll(transform.position, Vector2.one, 0, LayerMask.GetMask("Interact")); if (interactInRange.Length > 0) { for (int i = 0; i < interactInRange.Length; i++) { Interactible myInteract = interactInRange[i].GetComponent <Interactible>(); if (myInteract != null) { myInteract.EndExecute(); } } } } Debug.Log("Test dans PlayerController On move up"); if (grounded == true && climbingLadder == false && jumpKey == true) { Vector2 j_movement = new Vector3(0, 1.0f) * jumpSpeed; rb2d.AddForce(j_movement); grounded = false; FindObjectOfType <AudioManager>().Play("JumpSFX"); return; } // Process movement // flip if (i_movement.x != 0) { transform.localScale = new Vector3(scale * Mathf.Sign(i_movement.x), transform.localScale.y, transform.localScale.z); } if (climbingLadder && i_movement.y > -0.7 && i_movement.y < 0.7) { i_movement.y = 0f; } Vector2 movement = climbingLadder ? i_movement * moveSpeed : new Vector2(i_movement.x * moveSpeed, rb2d.velocity.y); rb2d.velocity = movement; animator.SetFloat("Velocity", Mathf.Abs(movement.x)); }