Circle Collision Detection vs. Tilemaps (1.7.2)
by Patrick Shaw · in Torque Game Builder · 02/18/2008 (6:41 am) · 3 replies
Hi,
In 1.7, I have noticed that objects with Collision Detection Mode to "circle" can get stuck or push through tilemaps. If I change the mode to "polygon", the object does not push through the tilemap.
Repro
1) Create a tilemap that looks like this:
Where the X's are collidable squares and the rest is empty space
2) For the tilemap, turn on receive collision and set the auto-rotation to 10.
3) Create a sprite that can send/receive collision with a circle collision mode. Place the sprite in empty space inside the tilemap. Set it to have constant force Y of 1.0.
4) Run the game.
Result
The sprite will start colliding normally with tilemap. However, over time, the sprite begins to poke through the tilemap and eventually pushes through one of the corners.
If the sprite's collision mode is changed "polygon", it does not poke through.
Note: This is not an artifact of the tilemap spinning - it happens in my other game projects with non-rotating tilemaps.
In 1.7, I have noticed that objects with Collision Detection Mode to "circle" can get stuck or push through tilemaps. If I change the mode to "polygon", the object does not push through the tilemap.
Repro
1) Create a tilemap that looks like this:
XXXXXXX X X X X X X XXXXXXX
Where the X's are collidable squares and the rest is empty space
2) For the tilemap, turn on receive collision and set the auto-rotation to 10.
3) Create a sprite that can send/receive collision with a circle collision mode. Place the sprite in empty space inside the tilemap. Set it to have constant force Y of 1.0.
4) Run the game.
Result
The sprite will start colliding normally with tilemap. However, over time, the sprite begins to poke through the tilemap and eventually pushes through one of the corners.
If the sprite's collision mode is changed "polygon", it does not poke through.
Note: This is not an artifact of the tilemap spinning - it happens in my other game projects with non-rotating tilemaps.
About the author
#2
After making this post, I discovered that problems with CIRCLE detection were not limited to tile maps. In the same thread you referenced, I asked Melv about CIRCLE detection mode and he says it works now.
As for the tilemaps disappearing, I haven't seen that problem since the original T2D beta two years ago. Does anything show up in the debug console?
03/31/2008 (7:09 am)
Wenceslao, After making this post, I discovered that problems with CIRCLE detection were not limited to tile maps. In the same thread you referenced, I asked Melv about CIRCLE detection mode and he says it works now.
As for the tilemaps disappearing, I haven't seen that problem since the original T2D beta two years ago. Does anything show up in the debug console?
#3
The tilemaps disappear when the TGB editor re-appears, not in game. So I press F5, the editor minimizes, game comes up, game finishes, editor maximizes and the tileLayer object is there but the tiles are gone. I can solve the problem by reloading the project but it's a bit annoying and I'm afraid of data loss. I'll see if I can find better repro steps.
03/31/2008 (10:02 pm)
You're right, I suppose I ran into the problem a while after reading that and didn't remember.The tilemaps disappear when the TGB editor re-appears, not in game. So I press F5, the editor minimizes, game comes up, game finishes, editor maximizes and the tileLayer object is there but the tiles are gone. I can solve the problem by reloading the project but it's a bit annoying and I'm afraid of data loss. I'll see if I can find better repro steps.
Torque Owner Wenceslao Villanueva Jr.
Class = "wheel";
Size = "10 10";
CollisionMaxIterations = "2";
CollisionActiveSend = "true";
CollisionActiveReceive = "true";
CollisionDetectionMode = "CIRCLE";
CollisionResponseMode = "RIGID";
CollisionCircleSuperscribed = "false"; //For circle collisions
CollisionCircleScale = 0.9;
ConstantForce = "0 80";
ConstantForceGravitic = "true";
Damping = "0.4";
//Density = "0.8";
Friction = "1";
Restitution = "1";
MinAngularVelocity = 29;
When I commented out the Density field the object stopped poking through the collision. Seems to be a collision issue of sorts where the collision detection is being broken by the constant force, maybe related to the issue Melv fixed described in this thread? www.garagegames.com/mg/forums/result.thread.php?qt=66114
Also, have you found that sometimes the tile layer, after running, TGB comes back up with the tile layer completely blank? I have to reload the project. I've even had it where I've made changes, ran, and the changes aren't there and when I got back to TGB, my changes are gone. Seems like the tile editor is really buggy.