Game Development Community

Snapping an object to a tile in a tilemap

by Shakey · in Torque Game Builder · 01/02/2010 (3:56 pm) · 6 replies

I have my game running, where can I go look for information on placing an object at game runtime on a specific tile on a tilemap, with the mouse.

#1
01/03/2010 (2:22 am)
use this behavior for the object that you want to snap

tdn.garagegames.com/wiki/TGB/Behaviors/Snap_to_Grid
#2
01/03/2010 (11:12 am)
Thanks, overall it works like I want it to. There is a slight problem though, I have my sceneobjects I want to snap to the tile layers in somewhat of a menu. If I click without dragging on the object, it places my object at the very first tile in the tilemap. Any suggestions
#3
01/04/2010 (11:36 am)
do you mean that you create one object, then without placing that object on the tilemap, you click on the menu to create another?

if yes, then simply delete the previous object if it's not placed, before creating another...
#4
07/02/2010 (11:33 am)
I was doing this same thing, and I was wondering how to check if a tile is already filled, so you don't get multiple objects stacked up on the same tile.
#5
07/03/2010 (9:20 am)
%data = tilemapName.getTileCustomData(%tileX,%tileY);

where %tileX,%tileY is your tile position
#6
07/03/2010 (9:57 am)
Ok thanks, that's a lot easier than how I was trying to do it.
Just to clarify for anyone else, getTileCustomData(%tileX, %tileY) stores any string that was set using setTileCustomData(%tileX, %tileY, %string);