Professional Documents
Culture Documents
Half Scprit
Half Scprit
Collections;
using System.Collections.Generic;
using UnityEngine;
// In the Update() method, check if the S key is pressed and the BoxCollider2D
is enabled
// If it is, disable the BoxCollider2D
// If the S key is released and the BoxCollider2D is disabled, enable the
BoxCollider2D
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;
}
// Get the horizontal axis input and multiply it by runSpeed, then assign
the result to horizontalMove
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
// If the Jump button is pressed, set jump to true and set the "IsJumping"
parameter of the animator to true
if (Input.GetButtonDown("Jump"))
{
jump = true;
animator.SetBool("IsJumping", true);
}
}