Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jump and Crouch Not Working #48

Open
AnshrajGamez opened this issue Oct 5, 2022 · 1 comment
Open

Jump and Crouch Not Working #48

AnshrajGamez opened this issue Oct 5, 2022 · 1 comment

Comments

@AnshrajGamez
Copy link

AnshrajGamez commented Oct 5, 2022

My code:

`using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
CharacterController2D controller2D;
float horizontalMove = 0f;
float runSpeed = 70f;
bool jump = false;
bool crouch = false;
// Update is called once per frame
void Update()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
if (Input.GetButtonDown("Jump"))
{
jump = true;
}

    if (Input.GetButtonDown("Crouch"))
    {
        crouch = true;
    }
    else if (Input.GetButtonUp("Crouch"))
    {
        crouch = false;
    }
}

void FixedUpdate()
{
    controller2D = GameObject.Find("Player").GetComponent<CharacterController2D>();
    controller2D.move(horizontalMove * Time.fixedDeltaTime, crouch, jump, controller2D.GetOnCrouchEvent());
    
}

}
`

@MinerMinerMods
Copy link

Hi there, do you have 2 hitboxes? If you don't then change your player's hitbox in to a top and bottom hitbox then input the top hitbox into hitbox disable. for anything else check the video here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants