Individual Tile collisions
by Bucko · in Torque Game Builder · 03/29/2005 (2:50 pm) · 3 replies
How do I set up the collision info for individual tiles of a tilemap?
I want to have different collision polygons on different tiles (some square, some triangle and some no collision at all).
How do I go about doing this through the tilemap editor (or any other way for that matter).
I couldn't find this in the tutorials nor the docs but please bear with me if this has already been answered.
My coworker for this game really want to see some bouncy stuff (10 year olds can get pretty impatient :)
I want to have different collision polygons on different tiles (some square, some triangle and some no collision at all).
How do I go about doing this through the tilemap editor (or any other way for that matter).
I couldn't find this in the tutorials nor the docs but please bear with me if this has already been answered.
My coworker for this game really want to see some bouncy stuff (10 year olds can get pretty impatient :)
About the author
#2
Calling setCollisionActive() on either the tilemap or its layer produces syntax errors so this doesn't seem to be the right way to do it. No matter what, my collision callback will not get called.
Any clue? has anybody else succesfully used tilemaps from the tileeditor with collisions?
03/30/2005 (11:49 am)
Great, now I want to have my damned sprite collide with the newly loaded tilemap.Calling setCollisionActive() on either the tilemap or its layer produces syntax errors so this doesn't seem to be the right way to do it. No matter what, my collision callback will not get called.
Any clue? has anybody else succesfully used tilemaps from the tileeditor with collisions?
#3
You'll need to set up corresponding masks for your player or anything else you want to collide with the tile.
Note: I've only copied snippets of my code, but I think thats everything thats relevant. Forum may do some funny line wraps :P
You may want setCollisionPhysics setting to true if you don't want to have to handle the physics your self. I just catch the collisions in on collision and react accordingly, as I don't need physics in my test game.
03/30/2005 (2:58 pm)
Bucko: Heres what I use for my arena wall collisions.// we could have one layer per level, or maybe one map per level?
%this.levelMap = new fxTileMap2D( masterTileMap ) { sceneGraph = t2dSceneGraph; };
%this.levelMap.loadTileMap( "~/client/maps/level" @ %levelNumber @ ".map" );
%w_layer = %this.levelMap.getTileLayer($Game::map::WALL_MAP_LAYER);
%w_layer.setPosition( "0 0" );
%w_layer.setTileSize( $Game::map::TILE_SIZE );
%w_layer.setWrap( false, false );
//setup default collision handling for tile map
%w_layer.setLayer( $Game::rendering::WALL_LAYER );
%w_layer.setGroup( $Game::collision::WALL_GROUP );
%w_layer.setCollisionMaterial( immovableMaterial );
%w_layer.setCollisionActive( false, true );
%w_layer.setCollisionCallback( true );
%w_layer.setCollisionMasks( BIT( $Game::collision::PLAYER_GROUP ) | BIT( $Game::collision::ENEMY_GROUP ),
BIT( $Game::rendering::PLAYER_LAYER ) | BIT( $Game::collision::ENEMY_LAYER ));
%w_layer.setCollisionPhysics(false, false); // we're using our own modelYou'll need to set up corresponding masks for your player or anything else you want to collide with the tile.
Note: I've only copied snippets of my code, but I think thats everything thats relevant. Forum may do some funny line wraps :P
You may want setCollisionPhysics setting to true if you don't want to have to handle the physics your self. I just catch the collisions in on collision and react accordingly, as I don't need physics in my test game.
Torque Owner Chris "Hyena" Vogel
You can then Ctrl-Click on a tile to edit it's collision polygon.