Game Development Community

FindObject not working with T2DTileLayer [RESOLVED]

by Randy Lutcavich · in Torque X 2D · 07/27/2009 (10:42 pm) · 4 replies

I'm using the following statement to find a previously made tilemap but the variable always ends up null.

_tilemap = TorqueObjectDatabse.Instance.FindObject<T2DTileLayer>("MyTilemap");

What am I doing wrong?

#1
07/27/2009 (10:58 pm)
Are you using the example from John's book?

Brian
#2
07/27/2009 (11:09 pm)
I'm using his book as a reference but I'm not doing any particular lesson. What I want to do is change the tile for the position that the player is located at after a button press.

I'm probably going about this the wrong way.

Right now I am creating the tilemap in game.cs in beginrun(). Then I am calling a ChangeTile method that is in a component that is attached to the player.

I just found the PickTile method so maybe that will help me.

I'm just not sure why my tilemap variable is null in the component.
#3
07/27/2009 (11:57 pm)
As long as it has the name filled out and has been registered with the Torque Object Datatbase using TorqueObjectDatabse.Instance.Register() you should be able to find it... unless it was made in TXB2D... then you need to make sure the name matches on the scripting roll out.

Brian
#4
07/29/2009 (6:55 pm)
It's working now! Not sure what fixed it but I changed a couple things around after re-reading chapter 7. I highly suggest for anyone having similar problems to check out this chapter in John's book as well. Thanks for your help Brian.