- Home /
My Character can't jump
He'll play the jump animation but he won't move. This was the tutorial I used: https://www.youtube.com/watch?v=dwcT-Dch0bA
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CharacterMovement : MonoBehaviour { public Character_Controller controller; float horizontalMove = 0f; public float RunSpeed = 40f; bool Jump = false; public Animator animator; bool Crouch = false;
void Update()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * RunSpeed;
animator.SetFloat("IsWalking", Mathf.Abs(horizontalMove));
if(Input.GetButtonDown("Jump"))
{
Jump = true;
animator.SetBool("IsJumping", true);
}
if(Input.GetButtonDown("Crouch"))
{
Crouch = true;
} else if(Input.GetButtonUp("Crouch"))
{
Crouch = false;
}
}
public void OnLanding()
{
animator.SetBool("IsJumping", false);
}
public void OnCrouching(bool IsCrouching)
{
animator.SetBool("IsCrouching", IsCrouching);
}
void FixedUpdate()
{
controller.Move(horizontalMove * Time.fixedDeltaTime, Crouch, Jump);
Jump = false;
}
}
Answer by bdubbert · Nov 01, 2021 at 10:49 PM
So it looks like your controller is of type Character_Controller but Brackeys is using CharacterController2D. Are you sure that you have the correct character controller script attached? You have to make sure you are using the one that he links in his video description, because that is a not a vanilla Unity component.
If you are using the correct script, are you sure that you have a large enough jump parameter on your CharacterController2D script?
Also check the rigidbody script attached to your character and make sure that it has "IsKinematic" set to false.
It still isn't working. Brackeys never told me to make a script for the rigidbody, and I don't see a setting about kinematics.
I apologize, it is a Rigidbody 2D script and so you would select "Dynamic" from the dropdown, there is no "IsKinematic" checkbox. He sets up this component at 5:00 in the video, make sure that you have it set up the same as him.
I did everything that he told me to do with the rigidbody, but he still won't jump.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Making a bubble level (not a game but work tool) 1 Answer
Using Mathf.Clamp To Limit Camera Movement 0 Answers
Implement moveSpeed to this object script? 1 Answer
Vector3.Lerp is flinging my character all over the place! 2 Answers