Draw Order... adding depth
by Tom Lenz · in Torque Game Builder · 02/13/2008 (7:49 am) · 2 replies
I was wondering if there is a way to get a player to be able to run behind and in front of an object in a game. I know there is a way but the complexity of it is the part that I might have a problem with. I think it has to do with the draw order but I don't know how to go about doing that.
I want to do something similar to what is show here twobrothersandasister.com/wp-content/images/2007/games/pixeljunk/mm1.jpg. The player can run behind and in front of the trees, but he can also interact with them. If you don't know the game it is a tower defense and you build your towers in place of the trees.
I was also curious if anyone has connected a wii mote or a sixaxis to TGB and how it functions within the engine and game. The last thing would be pathing. Is it possible to have a character walk a specific path. Any help would be great. Thanks
I want to do something similar to what is show here twobrothersandasister.com/wp-content/images/2007/games/pixeljunk/mm1.jpg. The player can run behind and in front of the trees, but he can also interact with them. If you don't know the game it is a tower defense and you build your towers in place of the trees.
I was also curious if anyone has connected a wii mote or a sixaxis to TGB and how it functions within the engine and game. The last thing would be pathing. Is it possible to have a character walk a specific path. Any help would be great. Thanks
#2
02/13/2008 (8:59 am)
Thanks that works great. Now hopefully I will be able to get the rest of the game this easily.
Torque Owner Gary Preston
You can achieve this with a combination of methods. Firstly for any items that MUST always be in the foreground you set the objects layer to 0. For any items that the player can never walk behind, for example a city scape in backdrop + sky etc you use higher layers such as 27-31.
Now lets assume your main play area where the player runs around and can run in-front or behind objects is on layer 10. You can make use of TGB's layer management system to fake depth. This can be found by clicking on the sceneGraph in the project tab/object tree then selecting the edit tab. You should see a "Layer Management" section.
The system can be setup a few ways, but the one you're probably looking for is to set the layer management for layer 10 to sort by "Y Axis". The result of this is that objects on Layer 10 are sorted based on their Y value, thus when the player's Y value is greater than an objects Y value (e.g he's higher up the screen), the player will be drawn behind the object. This gives the effect of running in-front or behind objects, although it does have a few limitations, but you can probably design around those.
Don't forget to edit the pivot point for your objects to be at the bottom of each object as this is the Y value that will be used in the comparison.