private void OnTriggerStay(Collider other) { if (other.tag == "Character") { if (other.GetComponent <Character>().isAlive == false || other.GetComponent <Character>().isControlled == false) { return; } managerUI.Pickup(true); if (Input.GetButtonDown("Input E")) { if (!isHidden) { // hide animator.Play("verstopKastDicht"); canExit = false; print("hide"); isHidden = true; characterThatIsHidden = other.GetComponent <Character>(); characterThatIsHidden.HideCharacter(true); sqeak.Play(); } } } }
private void OnTriggerStay(Collider other) { if (other.tag == "Character") { managerUI.Pickup(!Player.hasKey); if (Input.GetAxis("Input E") == 1 && !Player.hasKey) { Player.hasKey = true; managerUI.Pickup(false); } } }
private void OnTriggerStay(Collider other) { if(other.name == "Character Zusje") { managerUI.Pickup(true); if(Input.GetAxis("Input E") > 0) { other.GetComponent<CharacterController>().enabled = false; other.transform.position = exitPoint.position; other.GetComponent<CharacterController>().enabled = true; } } }
private void OnTriggerStay(Collider other) { if (other.tag == "Character") { managerUI.Pickup(true); if (Input.GetButtonDown("Input E")) { if (hasPlank == false) { hasPlank = true; plankMuur.SetActive(false); gameObject.SetActive(false); managerUI.Pickup(false); } } } }
private void OnTriggerStay(Collider other) { if (other.name == "Character Broer") { broer = other.gameObject; if (kastInPositie && broer.GetComponent <Character>().isControlled) { managerUI.Pickup(true); if (Input.GetAxis("Input E") > 0) { warpPos = exitPos.position; managerUI.Pickup(false); } } else { managerUI.Pickup(false); } } }
/// <summary> /// Used for ui /// </summary> /// <param name="index"></param> public void ChangeCharacter(int index) { if (currentCharacterControlling != null) { currentCharacterControlling.GetComponent <Character>().isControlled = false; // disable old one } currentCharacterControlling = characters[index]; // set new one currentCharacterControlling.GetComponent <Character>().isControlled = true; managerUI.currentCharacter = currentCharacterControlling.GetComponent <Character>(); managerUI.Pickup(false); }
private void OnTriggerStay(Collider other) { if (other.transform.tag == "Character") { if (other.GetComponent <Character>().isAlive == false) { return; } managerUI.Pickup(!hasBeenPickedup); if (Input.GetButton("Input E") && !hasBeenPickedup) { // pickup trowable print("pcikup"); hasBeenPickedup = true; other.transform.GetComponent <Character>().trowableAmount += 1; managerUI.Pickup(false); Destroy(gameObject); } } }
private void OnTriggerStay(Collider other) { if (other.tag == "Character") { if (PlankOppakken.hasPlank) { managerUI.Pickup(true); } if (Input.GetButtonDown("Input E")) { if (PlankOppakken.hasPlank) { plankGrond.SetActive(true); boxCollider.SetActive(true); StartCoroutine(GameObject.FindWithTag("Game Manager").GetComponent <BuildingNavmesh>().BuildNavMesh()); print("buildnav"); PlankOppakken.hasPlank = false; managerUI.Pickup(false); } } } }
// Update is called once per frame void Update() { // Update character state switch (state) { case CharacterState.idle: if (!hasEnteredNewState) { hasEnteredNewState = true; characterAnimator.Play(animNameIdle); } // Exit if (PlayerPressedInput()) { EnterNewState(CharacterState.walking); } break; case CharacterState.walking: if (!hasEnteredNewState) { hasEnteredNewState = true; if (isControlled) { characterAnimator.Play(animNameWalking); } } // Exit if (!PlayerPressedInput()) { EnterNewState(CharacterState.idle); } break; case CharacterState.death: if (!hasEnteredNewState && isAlive) { hasEnteredNewState = true; monsterBiteAnim.Play("MonsterBite"); characterAnimator.Play(animNameIdle); StartCoroutine(GameObject.FindWithTag("MainCamera").GetComponent <Player>().ShakeScreen(0.3f)); isAlive = false; lineRenderer.enabled = false; cursor.SetActive(false); characterSprite.flipX = false; managerUI.Pickup(false); UIHead.SetActive(false); } // Check anim finished if (monsterBiteAnim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1 && monsterBiteAnim.GetCurrentAnimatorStateInfo(0).IsName("MonsterBite")) { // Finished characterAnimator.enabled = false; characterSprite.gameObject.transform.localEulerAngles = new Vector3(0, 0, 90); characterSprite.gameObject.transform.localPosition = new Vector3(0, 1.73f, 0); } break; default: break; } if (!isControlled) { lineRenderer.enabled = false; } if (!isControlled) { return; } if (!isAlive) { return; } if (!canMove) { return; } // Movement moveDir = Vector3.zero; if (controller.isGrounded) { float h = Input.GetAxisRaw("Horizontal"); float v = Input.GetAxisRaw("Vertical"); // Flip sprite if (h == 1) { characterSprite.flipX = false; } else if (h == -1) { characterSprite.flipX = true; } moveDir = (v * Vector3.forward + h * Vector3.right).normalized; moveDir *= characterSpeed; } moveDir.y -= gravity; CheckGround(); ControllCharacter(); // Trowing if (!isHidden) { LaunchProjectile(); } if (isHidden) { lineRenderer.enabled = false; } else { if (Input.GetMouseButtonDown(1)) { if (trowableAmount > 0) { lineRenderer.enabled = true; } } } // Target Target.show = lineRenderer.enabled; // Enable/Disable cursor cursor.SetActive(lineRenderer.enabled); }