Game Development Community


#1
07/29/2009 (11:05 pm)
What I am trying to do is replace the tile that the player is standing over. I can use picktile() to get a reference to the tile type and then use it somewhere else but I don't know how to change that actual tile. I know of SetTileByGridCoords() but how do I get the local tilemap coords if I only have a reference to the world coords?
#2
07/29/2009 (11:24 pm)
I believe what is expected of me here is for me to change the tile type of the tile I am picking. Like this:

T2DTileType _baseType = new T2DTileType();
_baseType.Material = TorqueObjectDatabase.Instance.FindObject<GarageGames.Torque.Materials.RenderMaterial>("BaseMaterial");
tilemap.PickTile(new Vector2 (2, 2)).TileType = _baseType;

The only issue with this is that I am using that tile in multiple places in my tilemap and this way of doing things changes the tile type for every tile that shares the same tile type. Is there a way around this?
#3
07/30/2009 (12:22 pm)
I know I'm on the verge of figuring this one out. Can anyone out there push me in the right direction?
#4
07/30/2009 (7:14 pm)
I'm finding old references to a function:

::getTileLocalPosition

But it doesn't seem to exist anymore... or I just can't find out how to use it.
#5
07/30/2009 (8:49 pm)
I found what I was looking for. Thanks to Zilla... http://www.garagegames.com/community/forums/viewthread/86021

To get the grid coords of a tile that was found using PickTile() you just use .GridPosition:

Vector 2 tilePos = pickedTile.Gridposition;

Then you can set it:

tilemap.SetTileByGridCoords((int)tilePosx,(int)tilePosy, _differentTile);


This is very simple! The only problem is that it doesn't work for me. I just get the whole tilemap size returned, not the tiles grid position. I'm putting in a new post though... this one is too hectic.
#6
08/19/2009 (12:11 am)
Randy I advise you to try another strategy to handle your grids instead of using T2D tilemaps for that.

Its API is just not working right yet. I found this the hard way, when I spent a week trying to work with it. Then I gave up and created my own solution in less time than I wasted with tilemaps!
#7
08/20/2009 (1:55 am)
Diego, I know what you mean about tilemaps being more trouble than they are probably worth. Unfortunately, I don't know any other way to do what I have in mind.

I actually resolved the bulk of my issues with this thread

Now I'm just working on a way to create a custom movement component.