Game Development Community

Mini Platformer Tutorial related question

by Vern Jensen · in Torque Game Builder · 09/11/2006 (12:23 pm) · 7 replies

The mini platformer tutorial mentions that there is a way to change how the guy collides with the tiles, so that he can walk into them a little ways before he's stopped, or perhaps some of his head can go into a tile before it's stopped. That is, the collision rectangle is kind of shrunk.

But it doesn't say how to do this. It just says this is covered elsewhere on TDN. Where? I can't find it anywhere.

I'd really love to do exactly that. I think it might even provide a creative solution for the "sliding up the wall" problem.

#1
09/11/2006 (2:36 pm)
You'll want to create custom collision poly around the player sprite. You do this in the editor. Check the basic tutorial. I believe there is information in the collision tutorial as well.
#2
09/11/2006 (3:09 pm)
Oooh, not the answer I was hoping for. Because custom collision polys really mess up the sprite-tile collisions, so they go rather haywire. (Mini Platformer Tutorial.) So they're not really an option.
#3
09/11/2006 (3:13 pm)
Can you elaborate on "go rather haywire?" I am using a custom collision poly and am not experiencing any thing "rather haywire."
#4
09/11/2006 (3:26 pm)
Okay, I guess "haywire" is the wrong word. "Undesirable collision" would be more accurate, as on 2nd look, Torque is doing what makes sense, but not what's desirable in this situation.

To illustrate, make a "staircase" pattern of tiles, like so:

www.actionsoft.com/files/temp/tiles.jpg
Then have the player jump onto that from below, holding the left key, so he's jumping up/left. If he happens to bump the top-right corner of any tiles, this will send him *up* in the air, making him go higher, instead of falling to the ground. This is because I have a diagonal collision poly set up in the spot where he collided:

www.actionsoft.com/files/temp/collisionpoly.jpg
See the diagonal part in the lower-left? If that hits the corner of a tile, it'll do a collision in a way I don't want, but in a way that makes sense from a physics perspective.

It turns out that if I make a perfectly rectangular custom collision poly, the collisions work great. But the problem is, I need a non-rectangular collision poly for doing collision detection between my hero and enemies, enemy bullets, etc. So now I need TWO sets of collision polys: one that is used most of the time, for tile collisions, and another that I temporarily enable in order to do more precise collision detecting between the hero and the enemies, when checking to see if the hero should be killed.

I suppose that's workable (haven't tried it yet though). I was just hoping there would be a nicer solution.
#5
09/11/2006 (5:23 pm)
Quote:I need a non-rectangular collision poly for doing collision detection between my hero and enemies, enemy bullets, etc.

Why do you need a non-rectangular collision polly for this as a matter of intrest ?
#6
09/11/2006 (6:43 pm)
Quote:Why do you need a non-rectangular collision polly for this as a matter of intrest ?

Oh, that's an easy one. Let's say you have a bullet, and this bullet is moving at an angle. Let's say it's shot from the ground at a 45% angle. Now let's say your hero is standing *close* to the bullet, in such a way that the bullet passes through the hero's bouncing box, but does *not* actually touch him. Should he die? No!

But without a custom collision poly that's non-rectangular, this is impossible. He'll die if a bullet even passes *near* him at the correct angle.

Same thing goes for enemies. Let's say touching a bad guy kills you. Now let's say there is a bad guy about 1/4 the size of your hero that moves along floors. (A "slime" guy perhaps.) Should your hero die if the slime moves under the hero's hands, but doesn't actually touch his hands or his feet? No! But again, this is impossible with rectangular collision polys.

So ideally we'd be able to specify two different collision polys: one for "wall" type collisions, and another for "you're dead" type collisions. I'll have to experiment to see if I can fake this functionality by swapping the collision polys at the appropriate times.
#7
09/11/2006 (8:50 pm)
Or test the normal of the object your coliding with and make some asumptions based on that. Or even better, get the angle of the object the player is colliding with and make assumptions based on that.

Saves screwing with the bounding box.