- Home /
Character clips through ground for one frame and then back up,Character clips through ground for one frame and then back up, how do i fix this?
I have scoured the internet for a solution, tried changing the collision detection to continuous, increased linear drag, messed a bit with the code, but nothing apparently works! Everytime I jump and get a bit of speed, that is a random chance that my rectangle player will slightly clip through the ground for a sec and pop back up, and i have no idea why using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Jump : MonoBehaviour
{
[Range(1, 10)]
public float jumpVelocity;
bool jumpKey = false;
void Update()
{
if (Input.GetButtonDown("Jump"))
{
jumpKey = true;
}
}
private void FixedUpdate()
{
if (jumpKey)
{
GetComponent<Rigidbody2D>().velocity = Vector2.up * jumpVelocity;
jumpKey = false;
}
}
}
This is my code for the jumping, its just a really simple test game, i'm trying to get the basics down but this is getting on my nerves, and it is so small but SO ANNOYING that i can't focus on anything else
Idk if it matters, but all the platforms are just white squares with collision boxes in a 2d game
Your answer
Follow this Question
Related Questions
My OnCollisionEnter says i have 128 Collisions every collision 1 Answer
Physics2D.OverlapCircleAll and OverlapCapsuleAll behaves differently? 0 Answers
Is it possible to rotate a 2d collider in 3d? 0 Answers
problem solving ghost vertices with trigger and collision colliders 0 Answers
Unity 2D game: all colliders not working 3 Answers