Game Development Community

Mini platformer collision problems in TGB

by Wicked Sunny · in Torque Game Builder · 06/22/2007 (3:51 pm) · 10 replies

Hi everyone

I went through the mini platformer tutorial on TDN forums after buying TGb today.

After successfully making the ninja jump and run, the final problem I am facing is in collision of the tiles with the player.

Running on the tiles is not a problem.

1)When I jump it still sticks to the walls of the blue tile even though I have used the max iteration value of 2 in the script. Should I increase or decrease this value to get good results ?

2) Another problem is if I keep pressing the right( or left arrow key) against the side of the tile, slowly slowly the ninja starts rising until he jumps over the tile without pressing the jump button.

3) I realized in the tutorial the individual tiles collision polygons were not edited, so in the beginning my ninja was stuck half way near the center of the tile(instead of top edge).

I edited the polygon point within the tile editor and made it a square(bounding from all 4 side) and it solved the problem and I also made few one way platforms as well, through which I can jump through yet land on the top.

Now this polygon editing can be a reason for my above two problems but I am not sure about it.

4) even the square polygon shape of the ninja causes some trouble while falling between two tiles, I have read in the forums that dividing the player in different parts and editing their individual collision polygons can solve the problem.

But if I import the player animation in parts how exactly will I be able to combine them together - through animation builder or through scripting? Please can anyone help me regarding these problems or provide me a link if these problems are already solved in the past.

Regards

Sunny

About the author

Sunny is Multi Award Winning Poet, Writer, Designer and Chef. He is the Director of PublishingGurus.com, a book publishing company.


#1
06/22/2007 (5:14 pm)
I have decreased the max iterations to 0.5 and its not sticking anymore.

But I cannot solve the other 2 problems, thats while pressing the arrow keys player jumps over the tile slowly almost flying in the air.

and when falling between two tiles its getting stuck if it touches any of its sides.

any one can help ?
#2
06/23/2007 (10:35 am)
This is a problem with the collision system in TGB, so I wouldn't pursue it. I've created a superior platformer script with some pseudo-fixes, but even then there isn't much of a way to really fix it without messing with the source. Platformers in general won't work very well with the engine.
#3
06/23/2007 (2:32 pm)
Thanks Thomas

I did read the problems you were having. Almost similar problems I face and I know nothing much can be done about it until the bug is fixed.

thats why I am planning to shift to TXB with the platformer starter kit the collision problems are not this visible.

You can try out the TXB ( you must have got it free with TGB)

I have almost no background in programming but I am able to understand the stuff in the starter kit.

At least that template can help me make a similar game( even without programming)instead of wasting my time plumbing in TGB.

The more I give time to torque x and TXB the more I will learn to add in my own components( with scripting)
and hence make better games.

Even though derived from TGB , TXB has a better collision system thanks to few tweaks given in Starter kit.

Try it out if you stuck with platformers.
#4
06/23/2007 (7:15 pm)
Ok I solved one of the problems

instead of using collision in tiles I used invisible data objects and applied collision to them.

So tile map still remains as a show piece and the main collision work is done with data objects.

Now the ninja is not sticking or flying off a tile if running keys are pressed.
and I can even make slopes by editing the polygon collision of the data object.

I got this idea from the Torque x platformer starter kit. :)

But I still have a problem, the biggest - it still sticks to the wall when falling between two tiles.

I have made the collision mode of data object bounce but still ninja sticks .

Maybe this is more because of the scripting rather then collision bug.


I think its velocity is becoming 0 the moment it touches the wall of the tiles especially after being airborne..thats why it sticks and doesn't bounce back.


Can anyone help me with the scripting part ? I am not a programmer :(
#5
06/23/2007 (10:12 pm)
Ok problems solved. :) Ninja is not sticking anymore.

I have added an update to the mini platform tutorial wiki.

Thomas check it out. ;)
#6
06/23/2007 (10:30 pm)
Like I was saying previously, I am able to fix most of my issues. It just bothers me that I need to find a fix for it because the engine doesn't function the way it was intended, that's all. I'm sure a lot of problems would be resolved if the foundation was more secure.

EDIT

Also read your fix on that mini platformer tutorial - will give a word or two. The fact that the character road up a wall isn't really related to any bugs or anything of that nature - it was just bad coding. The behavior isn't that unusual - that is to say, you aren't going through a wall or having seizures or anything. What I'm saying is that wall and ceiling walking is simply an error of the code and the user. Cast collision isn't very reliable for detection when on the ground. Pickline is much more reliable. As far as a fundamental, basic script for platformers, I made a much more stable one than that shown on the mini-platformer. I also added some features like slope movement, acceleration, limited animation management, and angle modifications based on the slope of the surface. The angle mods are based entirely on collisions, so it works for single objects with a collision polygon.

My point is, the problem I have isn't with coding or bad coding. I've isolated all my problems down to the collision detection. I've noticed that TGB detects a collision every update, and corrects only one at a time. Instead of adding all the collision forces and calculating a remedial vector which agrees with all collisions, it corrects only one collision every update which will disagree with a collision the next update, causing some interesting effects such as shaking, passing through walls, outrageous physics responses, etc. I eventually solved even that issue by detecting how great a force is being applied to the player by input, and how much movement there actually is. If there is supposed to be a lot of movement, but instead there are little jitters, then input is cut off and all movement stopped until a direction change or another input is put in. That fixes the jitters, but not the passing through walls. After lots of experimentation I concluded the fundamental collision detection to be flawed and put it to rest.

Now, I was going to continue figuring this out after some venting on these forums, but as soon as I saw others were having a problem with the collision detection and I saw some replies regarding collisions being fixed, I figure I won't be able to solve this problem without modifying some source code, which I don't want to do. That being said, I did get that platformer starter kit and am messing with TGBX, mainly for the shader support and other added features. I think with a little of work, it will be a much better solution. Since I see a few people are interested in the whole platformer deal, I might post some fruits of my work as soon as I get a complete working system.
#7
06/23/2007 (10:44 pm)
I agree :)

edit -

Thomas the problems you mentioned above are exactly what I faced. Some times the player when moved on a wall will make the whole screen shaky.

Even when I made a perfect level once, the next time I load it up the ninja will stick to wall again.

obviously the core engine scripting has some problem with collisions.

I hope they are working on it thats why TGB 1.5 isnt out yet.

There are some problems with TXB platformer kit also - like when the character is on a slope screen starts shaking again but is comparatively (TGB) very less.

Currently I am stuck with it because when loading in XNA platforms(tile maps) go invisible for some reason.

I have no background in programming hence makes it very difficult for me and I am just a week old with TGB.

but I will not give up, will make a platform game soon enough, in TGB or in TXB. :)

The problems you have solved are they posted on the forums ? maybe I can learn something out of them.

Thanks for replying, every bit of information will help me move forward.
#8
06/24/2007 (9:56 am)
Well, unfortunately I refuse to post anything unfinished, so I don't want to show my script. I've introduced a few little glitches with the collision system because of my angle adjustment script that I didn't bother solving yet, among other minor things.
#9
06/24/2007 (7:52 pm)
No Problem Thomas.

Once you finish it maybe then you can post it for us, if you wish to.

Thanks anyhow.
#10
06/25/2007 (11:53 am)
Thomas

I have uploaded a demo of the game on the TDN. Have a look at it.