ForumsProgramming ForumFloor Collisions - Difficult To Handle!

4 5068
Solenix
offline
Solenix
6 posts
Nomad

Problem: Enemies that are affected by gravity fall through the floor when falling at higher speeds!

— I have no problems with flying enemies

— I have no problems with RIGHT & LEFT & TOP Collisions

What I do for right, left and top collisions is simply use while instead of if. It works out just fine, but when it comes to bottom collisions it crashes in an infinite loop! That’s why I can’t use while on bottom collisions. Only if.

The problem is that the code doesn’t react in time to push the enemies away because I’m not using while. It’s absolutely fine when the enemies fall a short distance, but as soon as en enemy falls off a high ledge, it will fall through the floor due to higher falling speeds.

I tried limiting the fall speeds but it’s an artificial way to fix it and it looks like they are on the moon. Which is not natural. Is there a way I could counter high speed collisions without using while?

Is there actually a way to use while for bottom collisions?

  • 4 Replies
Showing 91-90 of 4