Platformer - Movement and Collision
by Thomas Bang · in Torque Game Builder · 03/15/2008 (7:58 am) · 19 replies
Hi
I have now a basic Platformer Movement Script. But there is a bug.
I can move left and right. If i jump, the player is moving down to the next "block" under the player. No Problem.
But if i move AND jump, the player's head sticks in the wall.

Please look into the script. It is the complete project (also with a Torsion Project File) made with TGB 1.7.2...
www.darkware.de/MyPlatformerTest.zip
Thanks
Greetings
Thomas Bang
Germany
I have now a basic Platformer Movement Script. But there is a bug.
I can move left and right. If i jump, the player is moving down to the next "block" under the player. No Problem.
But if i move AND jump, the player's head sticks in the wall.

Please look into the script. It is the complete project (also with a Torsion Project File) made with TGB 1.7.2...
www.darkware.de/MyPlatformerTest.zip
Thanks
Greetings
Thomas Bang
Germany
#2
If you make the file available again I can test to see if the recent round of collision fixes solve your case.
Melv.
03/26/2008 (10:56 am)
Thomas,If you make the file available again I can test to see if the recent round of collision fixes solve your case.
Melv.
#3
03/26/2008 (1:53 pm)
It'd be great to actually have this problem fixed in the engine!
#4
thank you. The ZIP-File is online again. I made this test with TGB 1.7.2.
Don't wonder about the title ("PlatformerTestMac"). It is the Windows-Version of TGB.
There is also a second thing: I made a little ramp. If the player moves up everything is ok. But if the player moves down he jumps a little bit. You will see it in the same ZIP-File.
Thanks
Greetings
Thomas Bang
Germany
03/27/2008 (12:59 am)
Melv, thank you. The ZIP-File is online again. I made this test with TGB 1.7.2.
Don't wonder about the title ("PlatformerTestMac"). It is the Windows-Version of TGB.
There is also a second thing: I made a little ramp. If the player moves up everything is ok. But if the player moves down he jumps a little bit. You will see it in the same ZIP-File.
Thanks
Greetings
Thomas Bang
Germany
#5
I believe your demo is being affected by the collision interpenetration which has been fixed. I'll give it a try tonight when I get home.
Thanks for the help,
Melv.
03/27/2008 (1:26 am)
Downloaded successfully.I believe your demo is being affected by the collision interpenetration which has been fixed. I'll give it a try tonight when I get home.
Thanks for the help,
Melv.
#7
So I had a look at your level and the good news is that the player doesn't stick any more with the latest physics changes as can be demonstrated here: www.youtube.com/watch?v=9uSGjtdIfbY
One of the big problems you'll have constructing your levels from individual objects is that you've got to be really careful about the collision seams. It's easy to create gaps or protusions that cause an object to encounter an unwanted collision. Your ramp causes a problem because it has a small corner sticking up which can be seen if you zoom-in using the editor as shown here and here.
Also you've got a huge amount of collision detection going on in a scene where there's only a single object moving. This is a very common pitfall that people fall into. In your case you seem to have made most of the objects (not all) receive collision only which is correct and costs little CPU time. There are a few scenery objects that do send as well but those are probably just oversights.
There are a couple of objects with huge circular collision bounds that are sending/receiving collisions but have their physics turned-off so they don't achieve anything apart from creating lots of collision checks because they cover large parts of your level as shown here. If you turn on the debug-banner you'll see 400+ potential collisions per-frame which is huge for one object moving as shown here. Removing those big circular objects reduces this down to 100+. If only the player was sending collisions you'd probably have 5-6 potentials which is better than 400+.
Note that in the debug-banner the "BinCollis" is showing 704. This means that 704 bins are being searched per-frame resulting in 413 candidate objects of which 16 actually collide giving a poor 3.9% collision efficiency! These figures are big for such a simple level.
Melv.
03/27/2008 (7:24 am)
Thomas,So I had a look at your level and the good news is that the player doesn't stick any more with the latest physics changes as can be demonstrated here: www.youtube.com/watch?v=9uSGjtdIfbY
One of the big problems you'll have constructing your levels from individual objects is that you've got to be really careful about the collision seams. It's easy to create gaps or protusions that cause an object to encounter an unwanted collision. Your ramp causes a problem because it has a small corner sticking up which can be seen if you zoom-in using the editor as shown here and here.
Also you've got a huge amount of collision detection going on in a scene where there's only a single object moving. This is a very common pitfall that people fall into. In your case you seem to have made most of the objects (not all) receive collision only which is correct and costs little CPU time. There are a few scenery objects that do send as well but those are probably just oversights.
There are a couple of objects with huge circular collision bounds that are sending/receiving collisions but have their physics turned-off so they don't achieve anything apart from creating lots of collision checks because they cover large parts of your level as shown here. If you turn on the debug-banner you'll see 400+ potential collisions per-frame which is huge for one object moving as shown here. Removing those big circular objects reduces this down to 100+. If only the player was sending collisions you'd probably have 5-6 potentials which is better than 400+.
Note that in the debug-banner the "BinCollis" is showing 704. This means that 704 bins are being searched per-frame resulting in 413 candidate objects of which 16 actually collide giving a poor 3.9% collision efficiency! These figures are big for such a simple level.
Melv.
#8
Thank you very much. Today i learned a lot.
Can you send me the edited project? I want to look in detail at any difference between these two levels.
I wait until the next TGB-Version (with latest Physics- & Collision-Fixes) is out. Then i will create a new level with all your suggestions in mind.
You helped me a lot.
Thanks
Greetings
Thomas Bang
Germany
03/27/2008 (8:10 am)
Melv, Thank you very much. Today i learned a lot.
Can you send me the edited project? I want to look in detail at any difference between these two levels.
I wait until the next TGB-Version (with latest Physics- & Collision-Fixes) is out. Then i will create a new level with all your suggestions in mind.
You helped me a lot.
Thanks
Greetings
Thomas Bang
Germany
#9
Glad to help. The only permanent modification I made to your level was to move the "ramp" down slightly in the editor so that the little corner didn't stick up as per the image above and that's easy to do in the editor.
Melv.
03/27/2008 (8:16 am)
Thomas,Glad to help. The only permanent modification I made to your level was to move the "ramp" down slightly in the editor so that the little corner didn't stick up as per the image above and that's easy to do in the editor.
Melv.
#11
I had a problem locating them myself as they seem to be objects hidden underneath the horizontal levels and hard to select in the editor.
In the level file ("testlevel.t2d") they're the objects with class "BalkenClass" (Girder Class?). They have their collision mode set to "FULL" which uses circle then polygon detection.
Melv.
03/27/2008 (8:42 am)
Thomas,I had a problem locating them myself as they seem to be objects hidden underneath the horizontal levels and hard to select in the editor.
In the level file ("testlevel.t2d") they're the objects with class "BalkenClass" (Girder Class?). They have their collision mode set to "FULL" which uses circle then polygon detection.
Melv.
#12
Yes, Balken (de) is Girder (en). ;-)
I found and deleted these two objects.
Now i have these values:
PotCol : 10
ActCol: 3
ColHit: 30%
MaxCollis: 51
FPS: between 400 and 570
Much better than before.
Do you know the release date of the next TGB-Version?
Greetings
Thomas Bang
Germany
03/27/2008 (9:14 am)
Melv, Yes, Balken (de) is Girder (en). ;-)
I found and deleted these two objects.
Now i have these values:
PotCol : 10
ActCol: 3
ColHit: 30%
MaxCollis: 51
FPS: between 400 and 570
Much better than before.
Do you know the release date of the next TGB-Version?
Greetings
Thomas Bang
Germany
#13
Regarding the release I don't have that information as the changes are not yet finished.
Melv.
03/27/2008 (9:55 am)
Great, much better. :)Regarding the release I don't have that information as the changes are not yet finished.
Melv.
#14
One unexpected thing your test-level did was highlight that the "t2dTextObject" isn't rendering correct under the new tick-physics (due to some recent changes) when mounted so thanks for that. ;)
Melv.
03/27/2008 (11:13 am)
Thomas,One unexpected thing your test-level did was highlight that the "t2dTextObject" isn't rendering correct under the new tick-physics (due to some recent changes) when mounted so thanks for that. ;)
Melv.
#17
There are actually some very persistent graphical artifacts present with the text object for me, whether it is mounted or not. They're just lines that are a pixel in width around the bottom and right sides of the object. Moving the camera results in them freaking out a bit.
03/27/2008 (2:18 pm)
My current project boasts an outstanding 1500+ BinCollision. Thanks for explaining what some of those debug banner things mean, Melv. Very helpful. I think my gigantic triggers that cover half of the level may be causing some big problems.There are actually some very persistent graphical artifacts present with the text object for me, whether it is mounted or not. They're just lines that are a pixel in width around the bottom and right sides of the object. Moving the camera results in them freaking out a bit.
#18
I'm not too familiar with the t2dTextObject as I didn't write it but it sounds like some aspect of its rendering and you're seeing aliasing, possibly the background quad that's drawn. Can you post-up a screenshot of it? It's best to start a new thread on this one and post a link to it here.
1500+ ouch! Although it sounds like alot, most higher-end systems won't even sniff at that. It's when you move your game to something with a much lower-spec CPU you'll could see serious degredation. The worst thing is that it's CPU time that could be better spent on game-gloss. ;)
Melv.
03/27/2008 (2:24 pm)
Kevin,I'm not too familiar with the t2dTextObject as I didn't write it but it sounds like some aspect of its rendering and you're seeing aliasing, possibly the background quad that's drawn. Can you post-up a screenshot of it? It's best to start a new thread on this one and post a link to it here.
1500+ ouch! Although it sounds like alot, most higher-end systems won't even sniff at that. It's when you move your game to something with a much lower-spec CPU you'll could see serious degredation. The worst thing is that it's CPU time that could be better spent on game-gloss. ;)
Melv.
#19
03/27/2008 (3:28 pm)
With regards to the text object if you move it by 0.01 units in both x and y axis, it will clear that problem up for the time being.
Torque Owner Kevin James
www.garagegames.com/mg/forums/result.thread.php?qt=72919