private void OnTriggerEnter(Collider other) { MyPlayerInput player = other.GetComponent <MyPlayerInput>(); if (player) { levelLoader.LoadTargetLevel(targetScene); } }
void Awake() { Instance = this; inputActions = new MyInputActions(); inputActions.Default.move.performed += playerController.OnMove; inputActions.Default.move.canceled += playerController.OnMove; inputActions.Default.mouse.performed += playerController.OnMouse; inputActions.Default.click.performed += playerController.OnClick; }
private void OnEnable() { movement = GetComponent <AgentMovement>(); input = GetComponent <MyPlayerInput>(); myAnimations = GetComponent <MyAnimations>(); //input = GetComponentInParent<MyPlayerInput>(); //myAnimations = GetComponentInParent<MyAnimations>(); currentState = movementState; currentState.EnterState(this); AssignMovementInputListeners(); }
protected override void OnTriggerEnter(Collider other) { //base.OnTriggerEnter(other); if (other.CompareTag("HitBox") && other.transform == MyTarget) { speed = 0; other.GetComponentInParent <Animal>().TakeDamage(damage); Debug.Log("Impact"); Instantiate(explosion, transform.position, Quaternion.identity); rb.velocity = Vector3.zero; MyTarget = null; Destroy(gameObject); if (other.gameObject.GetComponentInParent <Animal>().CompareTag("Bear")) { //myPlayerInput.GetComponentInParent<MyPlayerInput>(); myPlayerInput = FindObjectOfType <MyPlayerInput>().GetComponent <MyPlayerInput>(); myPlayerInput.isBear = true; myPlayerInput.isPlayer = false; myPlayerInput.isWolf = false; myPlayerInput.bear.SetActive(true); myPlayerInput.player.SetActive(false); myPlayerInput.wolf.SetActive(false); myPlayerInput.myAnimations.animator = myPlayerInput.transform.GetChild(1).GetComponent <Animator>(); myPlayerInput.canJump = false; } myGameObject = other.GetComponentInParent <Animal>().gameObject; myGameObject.SetActive(false); //other.GetComponentInParent<Animal>().gameObject.SetActive(false); UIManager.MyInstance.HideTargetFrame(); //myGameObject.StartCoroutine(myGameObject.ResetAnimal()); //animal.isActive = false; } }
//public GameObject player, bear, wolf; private void Start() { characterController = GetComponent <CharacterController>(); agentAnimations = GetComponent <MyAnimations>(); myPlayerInput = GetComponent <MyPlayerInput>(); }
void OnDestroy() { Instance = null; }