Collisions between player and map layers?
by C. N. · in Torque Game Builder · 09/15/2005 (9:41 pm) · 8 replies
Hi,
I'm just trying to set up collisions between my player and the map. I'm just trying some simple side-scroller concepts... I noticed in the Basic Tutorial that collisions are setup with Groups and Layers. Are these Layers the same layers that are in the tile-editor? For example, my tilemap is a very simple map, just two different types of tiles: I've got clouds filling the entire map (layer 0) except the very bottom row (layer 1, for the ground). Is this how I specify which tiles are collision-ready, with the layers from the tile editor? If so, how do I specify which tiles the player can't pass through?
Thanks again for any advice.
I'm just trying to set up collisions between my player and the map. I'm just trying some simple side-scroller concepts... I noticed in the Basic Tutorial that collisions are setup with Groups and Layers. Are these Layers the same layers that are in the tile-editor? For example, my tilemap is a very simple map, just two different types of tiles: I've got clouds filling the entire map (layer 0) except the very bottom row (layer 1, for the ground). Is this how I specify which tiles are collision-ready, with the layers from the tile editor? If so, how do I specify which tiles the player can't pass through?
Thanks again for any advice.
#2
$player.setCollisionMask(0, 1);
...
%map = new fxTileMap2D() { scenegraph =t2dSceneGraph; };
%map.loadTileMap("~/client/maps/levelOne.map");
$layerOne = %map.getTileLayer(1);
$layerOne.setCollisionMask(0, 1); // (?)
...or am I doing it the wrong way?
In the tutorial, it's got "BIT(etc), BIT(etc)" as the parameters for setCollisionMask(). It's ok to use the "0, 1" instead?
09/15/2005 (10:19 pm)
Ah, so would I set it up kinda like this:$player.setCollisionMask(0, 1);
...
%map = new fxTileMap2D() { scenegraph =t2dSceneGraph; };
%map.loadTileMap("~/client/maps/levelOne.map");
$layerOne = %map.getTileLayer(1);
$layerOne.setCollisionMask(0, 1); // (?)
...or am I doing it the wrong way?
In the tutorial, it's got "BIT(etc), BIT(etc)" as the parameters for setCollisionMask(). It's ok to use the "0, 1" instead?
#3
I think at some point Melv changed the input params for setCollisionMasks so we didn't need the BIT conversions. I can't remember offhand, though. But yeah, (0, 1) will work, no need for BIT. :)
09/15/2005 (10:25 pm)
Sorry, that should have been setCollisionMasks().I think at some point Melv changed the input params for setCollisionMasks so we didn't need the BIT conversions. I can't remember offhand, though. But yeah, (0, 1) will work, no need for BIT. :)
#4
Slight problem... when I open the console it tells me that:
'fxSceneObject2D::setCollisionActive - Send collision not allowed for this object!'
It's referring to the 'layerOne', because if I remove the layerOne collision setup the above console message doesn't appear. I'm definately doing something wrong, lol.
09/15/2005 (10:33 pm)
Ah,Slight problem... when I open the console it tells me that:
'fxSceneObject2D::setCollisionActive - Send collision not allowed for this object!'
It's referring to the 'layerOne', because if I remove the layerOne collision setup the above console message doesn't appear. I'm definately doing something wrong, lol.
#5
However, if you still have any advice I'd love to hear it...
Thanks for the response. :)
Edit:
Actually, the physics tutorial doesn't show how to set up collisions with tilemap layers, just fxStaticSprite2D's which won't help me much (at least with tile map collisions?). Dang, back to where I started, heh.
09/15/2005 (10:43 pm)
Oops, I guess I should look at my files once in a while, eh? I have the T2D physics tutorial which conveniently covers tile collisions... However, if you still have any advice I'd love to hear it...
Thanks for the response. :)
Edit:
Actually, the physics tutorial doesn't show how to set up collisions with tilemap layers, just fxStaticSprite2D's which won't help me much (at least with tile map collisions?). Dang, back to where I started, heh.
#6
09/15/2005 (11:33 pm)
Um, nevermind... It seems to be working now. :)
#7
Any clues?
08/24/2009 (12:47 am)
hopefully, one of you is still there. My player is falling thru my tile map, well, until he hits the lowest (actually highest Y+++)point. so he hides behind the map. I can move him, map is half his vertical size.Any clues?
#8
09/05/2009 (5:19 am)
same problem here. My lil Space Ninja just drops straight through to china! I', screwing around with the tile layers/groups and the players but cant get it so far. help?
Torque Owner Teck Lee Tan
edit: Oh, right, and after that you'll still have to set the collision behavior, otherwise all that will happen is that the engine receives a collision callback but doesn't actually stop interpenetration. Enabling physics would be one way, or you could roll your own response in the onCollision callback.