Game Development Community

Platformer issue - setting up collision groups

by Matt Troup · in Torque Game Builder · 10/10/2006 (12:53 pm) · 3 replies

Hi all,

I've used the platformer tutorial which seems to work okay thus far unless I have enemies/NPC's/Triggers envolved. I've tried using collision groups to sort out what's what (via script and level editor), but I can't seem to get the desired effect. Can someone shed a little light on what to do?

Here's my scenario:

I have my player, the tilelayer, an NPC, and a trigger.

1) I want my player and tilelayer to collide (havethe tilelayer hold the player up).
2) I want the NPC to interact with the trigger (on Enter).
3) I want my player to pass through but call a collision with the NPC... but not clamp to it, etc.

I can always get two out of three of these features.

I can't seem to have my player walk on a platform without its bounding box interfering with the NPC and Trigger. I've tried mingling with setting receive/send collisions active and collision groups, but I can't seem to find anything that fits the bill.

I've tried searching... I guess I'm posting this in case someone says "it's not suppose to work that way".

#1
10/10/2006 (9:52 pm)
Did you ever actually set your objects to different layers and groups? Setting the collision layers simply sets what layers the object can collide with. Same with setting collision groups.

Check out the last entry in this thread.

That help at all?

I actually have something extremely similar to what you're describing. A trigger, some NPC-equivalent objects, and the tileLayer. I got everything to run smoothly but it took some playing to get things just right (had to figure out where to enable collision/physics responses and get a grasp on how that works...).
#2
10/10/2006 (10:28 pm)
Without going into too much detail about the whys and hows, what you want is the following:

Each type of object in your world should have a different collision group (player, platform, enemy, etc. - consider creating globals to store these values).

Tile layers can only receive collision, so you set their graphGroup to something specific to platforms. They should have receive physics turned on. Immovable should be turned on.

You player has to have send collision and receive collision turned on and must have the platform group in its collisionGroups. The player must also have send physics turned on if you want your player to have a physics response when a collision occurs with a reciever (platforms, for example). Receive physics should be off.

Triggers never have physics responses by design, but must be in one of your NPC's collisionGroups. Specifically, a graphGroup that is not in your player's collisionGroups so your player can't collide with the triggers and the triggers aren't checking for collisions against objects that don't care about them. Make sure send collision is off on your triggers.

Your NPC's must have send collision on (presumably with the platform graphGroup in their collisionGroups so they can stand on platforms aswell), receive collision is optional. Physics send should be off, and physics receive should be off (unless you need it later). The player's graphGroup should be in the collisionGroups.

If you set it up right, your NPC's should get a callback but not a physics response when they collide with your player, your NPC's should invoke the trigger callbacks, your player should pass right through your NPC's, and both your NPC's and your player should be able to stand on platforms.

Let me know if you have any trouble.
#3
10/11/2006 (1:53 am)
GraphGroup. That's it. I was using collisionGroups/collision layers (I think that was my natural instinct because those are the options visible within the level editor).

Everything works splendid.

Thanks so much for your help, Thomas.