Answer the question
In order to leave comments, you need to log in
Unity buggy detecting Grounded?
Hello.
I'm writing a 2D platformer.
On the Internet in classic scripts for the character of the 2D controller, the definition of the player on the ground in the classics, the following code is used everywhere:
grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
//вертикальная скорость
vSpeed = GetComponent<Rigidbody2D>().velocity.y;
//определяем, на земле ли персонаж
if (vSpeed == 0) {
grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
} else {
grounded = false;
}
Answer the question
In order to leave comments, you need to log in
Shorty decided.
Created a layer (Layer) =Ground, marked all platforms with this layer.
In the CharacterController, in the WhatIsGround field, unchecked the Default checkbox.
And that trick is gone.
It was necessary to do everything exactly like this, according to the mind, but I didn’t know.
Physics2D.OverlapCircle returns you a Collider2D. Look at what kind of collider it is, maybe you will understand what your character intersects with.
something like this:
Collider2D collider = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
Debug.Log(collider.name);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question