Game Development Community

It's maybe a Bug

by Firas · in Torque Game Builder · 10/06/2006 (12:49 am) · 24 replies

Hi guys

I was playing with the miniPlatformer tutorial alot in the last 3 days and I found somthing:

the movement of the player is very good and smooth until you define a custome collison polygon for your player, so if you define a collision polygon for the player you will have some problem with movement speacilly the jump key, you will press space bar many times to make your player jump and it will stuck alot on some corners.

I know this sound strange but please give it a try.

waiting for replay

thanks
Page«First 1 2 Next»
#21
10/11/2006 (7:51 pm)
@All: The issue arising in the miniPlatformerTutorial is a mixture of Tutorial/Source Code bugs.

Here's what happens:

We have our physics response set to CLAMP. As Thomas points out, this response mode kills all linearVelocity into the collision. When you have a flat, horizontal platform, then, the result is that linearVelocityY gets set to zero. But what of linearVelocityX?

Linear velocity X doesn't get killed. Essentially, if we didn't "setLinearVelocityX(0)" when we let go of both movement keys (left or right as per the tutorial) then we would slide across the platform. We don't get stuck in the platform when we let go of the movement keys before landing because we have "setLinearVelocityX(0)", clearing all horizontal linear velocity. The only velocity left is vertical and that gets wiped by the CLAMP response.

So why do we get stuck?

We get stuck when we land while holding movement keys, not because CLAMP kills it, but because our horizontal velocity does.
$pGuy.setLinearVelocityY(0);
%collision = $pGuy.castCollision(0.005);
if(%collision !$= "" )
{
    [b]$pGuy.setLinearVelocityX(0);[/b]
}
But, wait a minute, we set LinearVelocityY to zero before the check so we shouldn't be bumping at all, right? Right. Here's where the source code bug comes in. If you have a non-parallel edge in your collision polygon doing the colliding (if your polygon collides with the surface on a vertex), then the polygon goes in slightly and the engine registers a collision. It seems that point-line collisions are... touchy... Whatever happens (I can ignorantly think up a myriad of possible areas where the bug could lie) our test for collision in the previous sceneUpdate doesn't return a collision below the player and we move down and, probably, collide. Then, when we test for collision against the x we are told that we actually are colliding and we're... stuck. (Reading into this could point to a bug in the way setLinearVelocity(%velocity) works... Does the setting affect the value immediately or is it only set at the end of a frame update like "setImpulseForce"?) Whatever... something's busted.

Having completely parallel edges stops this bug from happening (at least with 'nice' decimals defining the points... not something like 0.673).

What my code does is it isolates the above code for use only when the player is airborne, keeping it from breaking when we have that odd collision case resulting from the source code bug.

This does not currently fix bumping your head against the ceiling, it seems. Perfectly parallel 'head' collision polygon edges should alleviate the issue, though.

So,
@Firas: Are the bases of your platforms/tiles slanted at all? Or they entirely horizontal? Did you set your own, custom collision for them?
#22
10/12/2006 (12:03 am)
Eric:

No my platforms/Tiles is not slanted at all, they are entirely horizontal, (the same environment we build in miniPlatformerTutorial).

for the tiles there is no custom collision for them.

but for the pGuy yes there is a custom collision polygon and I show it to you and we fix it together and here is it a gine:
CollisionPolyList = "0.900 0.418 0.486 1.000 -0.699 1.000 -0.910 0.129 -0.910 0.024 0.185 -0.550 0.241 -0.550 0.900 0.265";

this is working perfectly with the ciling if you colide with the ciling vertically there will be no stucking at all but the problem is when you jump while pressing left or right movemnet key your player will stuck in the ciling, please note that you can move horizontally after you stcuk in the ciling but you can't get back to the ground.

here is a pic. descripe the problem:
img214.imageshack.us/img214/3100/stuckmv1.jpg
#23
11/04/2006 (1:12 pm)
I had the same problem here's a thread on how I fixed it:

http://www.garagegames.com/mg/forums/result.thread.php?qt=53321

I did define a custom poly in the level editor.

Steve
#24
11/04/2006 (4:51 pm)
Firas' problem was fixed by recreating the tileLayer and tileMap. After he redid everything and used the updated code from the tutorial, he no longer experienced the ceiling-sticking issue.
Page«First 1 2 Next»