You are on page 1of 1

public CharacterController2D controller;

public Animator animator;


public BoxCollider2D bc;
public float runSpeed = 40f;

float horizontalMove = 0f;


bool jump = false;

void Start()
{
bc = GetComponent<BoxCollider2D>();
}

// Update is called once per frame


void Update()
{
if (Input.GetKeyDown(KeyCode.S) && bc.enabled == true)
{
bc.enabled = false;
} else if (Input.GetKeyUp(KeyCode.S) && bc.enabled == false)
{
bc.enabled = true;
}
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

animator.SetFloat("Speed", Mathf.Abs(horizontalMove));

if (Input.GetButtonDown("Jump"))
{
jump = true;
animator.SetBool("IsJumping", true);
}

You might also like