- Home /
Object bounces without colliding
I created a 2D platform with a 0.25 bounce material. One of my character's movements is an air dash, in which he's accelerated in a certain direction at high velocity for a short period of time.
When I air dash into a bouncy surface, I noticed through frame-stepping that my character's collider is not even touching the platform's collider. This is causing the ground detection to fail. Here are three screencaps of the frames where the character should be touching the ground:
http://i.imgur.com/TFPkDvt.png - character is falling
http://i.imgur.com/av1b42G.png - character bounces
http://i.imgur.com/zVDPMOO.png - character is rising again, without touching the platform collider and triggering the ground detection
I understand that hitting a bouncy surface at high velocity will cause a high bounce, but why does that result in the character not making contact with the material?
Answer by lordlycastle · Mar 26, 2015 at 11:01 PM
If the character is too fast then, the Physics engine might not be able to calculate the collision. Set the collision detection to continuous dynamic of the rigid body of the character. Also 0.25 is not that bouncy, the character will only reflect with 25% of the velocity it hit. The reason for not seeing him hit the ground could be because low frame-rate. If you using your own ground detection solution, then it could be issue in your code.
$$anonymous$$y ground detection code uses OverlapCircle. Is there a better way of doing it? Increasing the radius of the ground detect circle solves this problem, but then the player is detected as being grounded when they're visibly a few pixels above the ground. I assume the same would happen if I used a raycast and increased the range at which grounded
is true.
@_eternal I have never used OverlapCircle
so can’t say if it’s good, but if I was in your situation I would use Raycast
. With Raycast
you can make it so that there is no visible pixels below the player. Ofc, if you increased the length of the ray it’ll act likewise.