Collision test | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Collision test

Ok, I'm programming a platform game in Actionscript (flash) and I have a problem: Imagine your platform game character is falling, falling at a million pixels a frame; every frame, the code checks if your character is touching the ground, if it is, it stops falling, and if not, it keeps falling. Now think of this: your character is still falling a million pixels per frame, but, at one point, it is only ten pixels higher than the ground, which is 10 pixels thick. It will keep falling, right through the platform, even though we programmed it to stop falling when it hits a platform. Why is this? Since it is falling so quickly, it skips through the platform. How do we fix this? Well, an obvious solution would be to make the platforms thicker, or make your character fall more slowly, but say you don't want either. Let me just save this first. I came up with this:

30th Oct 2018, 12:39 PM
Theprogrammers - avatar
2 Answers
+ 3
You can check if two objects are touching, or if an object is touching a point.
31st Oct 2018, 12:30 PM
Theprogrammers - avatar
+ 2
My answer might not be practical but can it be done by checking the reverse way. i.e. when platform collides to the player. It might seem odd solution but might work.
30th Oct 2018, 1:22 PM
Niush - avatar