Tile Layers
by Cameron Aycock · in Torque Game Builder · 09/25/2005 (1:44 pm) · 3 replies
Not sure if anyone has had to deal with this issue yet, but curious to see what I can get for replies.
How would you deal with tilemaps that need to be passed in front of or behind by a player? For instance, let's say there's a staircase banister.. and you want the player to be able to pass behind it up to the point where his feet would touch the 'base' of the banister. But then, on the other hand, if the player were to walk around the rail and go down the stairs, his head/upper body would need to pass in front of the railing.
With layers, I always seem to have the player walking either under the rail layer or over the rail layer. Same issue with like large columns.. I would need the ability to pass in front of and behind the column.
Any suggestions?
How would you deal with tilemaps that need to be passed in front of or behind by a player? For instance, let's say there's a staircase banister.. and you want the player to be able to pass behind it up to the point where his feet would touch the 'base' of the banister. But then, on the other hand, if the player were to walk around the rail and go down the stairs, his head/upper body would need to pass in front of the railing.
With layers, I always seem to have the player walking either under the rail layer or over the rail layer. Same issue with like large columns.. I would need the ability to pass in front of and behind the column.
Any suggestions?
#2
setLayer(%layerNumber): controls the rendering order of various objects.
setGroup(%groupNumber): controls the collision of various objects.
With these two, you could do something like a dynamic layering system where if the coordinates of the player object indicate that he "is in front of" the bannister, he would be in a Layer that would render before the bannister. If he is in the situation where he would be colliding with the bannister (walking up?), they would need to be in the same collision group (maybe the "base" of the bannister is in the same collision group as the player). If he is "behind" the bannister, then he would be in a Layer that renders before the bannister (therefore the bannister renders on top).
09/26/2005 (8:31 am)
Teck is absolutely on the right track here...I've wondered about this for quite a while myself, and part of my research this weekend pointed out two very useful functions:setLayer(%layerNumber): controls the rendering order of various objects.
setGroup(%groupNumber): controls the collision of various objects.
With these two, you could do something like a dynamic layering system where if the coordinates of the player object indicate that he "is in front of" the bannister, he would be in a Layer that would render before the bannister. If he is in the situation where he would be colliding with the bannister (walking up?), they would need to be in the same collision group (maybe the "base" of the bannister is in the same collision group as the player). If he is "behind" the bannister, then he would be in a Layer that renders before the bannister (therefore the bannister renders on top).
#3
A very difficult issue.
Now, depending on your architecture, these don't even need to be separate layers. If you don't have places where the character can actually stand under or over some position, then you only need one layer.
Otherwise, you're going to have to deal with some rendering order issues here.
This is best done with either a layer approach or you need to actually change the order in which T2D renders stuff.
The layer mechanism is very simple: the pillar is split into two pieces. The bottom piece (the bottom-most tile of the pillar) is on the walking layer and the rest is on the "above" layer. Everything is taken care of for you.
The other mechanism is a more general-purpose solution, and only useful if you really need the character to walk behind and in front of the exact same tile (the layer mechanism, by contrast, means that the bottom of the column has a collision volume that prevents the player from moving directly behind the column). And you should only consider this for circumstances where you need such functionality, as it involves a lot of work. In short, it's better to change the art where possible than to actually do this.
Basically, you need to modify the order in which T2D render's stuff in a layer. Effectively, you alter the code to make it render things in a top-to-bottom render order. Also, you need to be able to differentiate between "floor" tiles and non-floor tiles, so that all floor tiles are rendered before non-floor tiles.
In general, it's best to just restrict the art a bit and use the layer-based mechanism.
09/26/2005 (1:13 pm)
Quote:How would you deal with tilemaps that need to be passed in front of or behind by a player?
A very difficult issue.
Now, depending on your architecture, these don't even need to be separate layers. If you don't have places where the character can actually stand under or over some position, then you only need one layer.
Otherwise, you're going to have to deal with some rendering order issues here.
Quote:With layers, I always seem to have the player walking either under the rail layer or over the rail layer. Same issue with like large columns.. I would need the ability to pass in front of and behind the column.
This is best done with either a layer approach or you need to actually change the order in which T2D renders stuff.
The layer mechanism is very simple: the pillar is split into two pieces. The bottom piece (the bottom-most tile of the pillar) is on the walking layer and the rest is on the "above" layer. Everything is taken care of for you.
The other mechanism is a more general-purpose solution, and only useful if you really need the character to walk behind and in front of the exact same tile (the layer mechanism, by contrast, means that the bottom of the column has a collision volume that prevents the player from moving directly behind the column). And you should only consider this for circumstances where you need such functionality, as it involves a lot of work. In short, it's better to change the art where possible than to actually do this.
Basically, you need to modify the order in which T2D render's stuff in a layer. Effectively, you alter the code to make it render things in a top-to-bottom render order. Also, you need to be able to differentiate between "floor" tiles and non-floor tiles, so that all floor tiles are rendered before non-floor tiles.
In general, it's best to just restrict the art a bit and use the layer-based mechanism.
Torque Owner Teck Lee Tan