using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerInput : MonoBehaviour { public Animator animator; public PlayerController pCont; public int maxJumps = 2; public int currentJumps = 0; public float jumpAdd = 2; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { float xDir = Input.GetAxis("Horizontal"); if(xDir == 0) { //not moving; animator.SetBool("PIdle", true); animator.SetBool("PRun", false); } else { animator.SetBool("PRun", true); animator.SetBool("PIdle", false); //Moving; } if(Input.GetKeyDown("j")) { animator.SetTrigger("PAttack"); } if(Input.GetButtonDown("Jump") && currentJumps < maxJumps) { pCont.JumpUnconditionally(); currentJumps++; animator.SetTrigger("PJump"); } if(pCont.landed) { currentJumps = 0; animator.SetTrigger("PLand"); } else { animator.ResetTrigger("PLand"); } if(!Input.GetButton("Jump")) { pCont.CancelJump(); } if(Input.GetButtonDown("Crouch")) { pCont.Crouch(); } if(Input.GetButtonUp("Crouch")) { pCont.UnCrouch(); } pCont.Move(xDir); } private void OnTriggerEnter2D(Collider2D collision) { if(collision.tag == "JumpBoost") { pCont.jumpForce += jumpAdd; } } }