infinite jump problem from brackeys script,i have infinite jumping issues
this is my third project in unity 2d in my previous projects jumping worked fine no errors
but here my character infinite jumps;
i followed Brackeys Tutorial.
my code;
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class playermovement : MonoBehaviour {
public CharacterController2D controller;
public Animator animator;
private bool IsJumping;
public float runspeed = 45f;
float horizontalmovement =0f;
bool jump = false;
bool crouch = false;
// Update is called once per frame
void Update() {
horizontalmovement = Input.GetAxisRaw("Horizontal") * runspeed;
animator.SetFloat("Speed", Mathf.Abs(horizontalmovement));
if (Input.GetButton("Jump") && !IsJumping)
{
jump = true;
animator.SetBool("IsJumping", true);
IsJumping = true;
}
if (Input.GetButtonDown("Crouch"))
{
crouch = true;
}else if (Input.GetButtonUp("Crouch"))
{
crouch = false;
}
}
public void FixedUpdate()
{
//Move our character
controller.Move(horizontalmovement * Time.fixedDeltaTime, crouch, jump);
jump = false;
}
public void OnLanding ()
{
animator.SetBool("IsJumping", false);
}
public void OnCrouching (bool isCrouching)
{
animator.SetBool("IsCrouching", isCrouching);
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Ground"))
{
IsJumping = false;
}
}
}
i didnt even change my script my ground and ceilings are also correct i even told the script what is ground by choosing ground layer my ground(platform) is also set to ground layer i even copied the layer name from my previous projects + i noticed one thing that my characters y position is increasing very quick i have a rigidbody2d in my character a collider2d everything but nothing is happening
HELP PLZZ
Your answer
Follow this Question
Related Questions
How to move character controller on x, z, AND y axes? 2 Answers
Controller script active on both characters. 1 Answer
Error CS0103 0 Answers
I can't seem to get this movement + automatic lookat the direction of movement work for a 2.5D game 0 Answers
Jumping with non-rigid character.,Dragged object Enters Ground freely 0 Answers