Depth strange case!

kdo

Member
Hello guys, i have a strange problem here, my game has a large stage so i need to spawn an entity , a little smoke thats come from the ground, its works fine with alpha and a use it in some places on the ground and others in back ground areas like chimney and exhaust fans, and its works judt fine. Whats is strange for me is , if spawn the smoke at some area near the end of my stage its apears behind the beckground layer, but its the same entinty spawned before in other part of the stage in correct layer, this entity hasnt set layer in his flag.
What could it be? how can i adjust this ?
 
Hi @kdo, it's difficult to tell what's going on just from the description. Please post some screenshots and include the the spawning text in code tags. That will help us diagnose.

DC
 
OK!

The Smoke entity:

name smk
type npc
health 9999
nomove 1
facing 1
#gfxshadow 0
offscreenkill 10000

alpha 1


anim spawn
loop 1
delay 12
offset 18 45
frame data/npcs/smk/1.gif
frame data/npcs/smk/2.gif
frame data/npcs/smk/3.gif
frame data/npcs/smk/4.gif
frame data/npcs/smk/5.gif
frame data/npcs/smk/6.gif
frame data/npcs/smk/7.gif
frame data/npcs/smk/8.gif
frame data/npcs/smk/9.gif

anim idle
loop 1
delay 12
offset 18 45
frame data/npcs/smk/1.gif
frame data/npcs/smk/2.gif
frame data/npcs/smk/3.gif
frame data/npcs/smk/4.gif
frame data/npcs/smk/5.gif
frame data/npcs/smk/6.gif
frame data/npcs/smk/7.gif
frame data/npcs/smk/8.gif
frame data/npcs/smk/9.gif

Level spawn:

spawn smk
coords 1346 229
at 0

spawn smk
flip 1
coords 3709 95
at 0

PS: the second spawned entity has the issue



Level txt:

set Start_Game

skipselect Agnes
scene data/scenes/enter.txt
disablegameover 1
disablehof 1
z 183 243 183
file data/levels/stg2.txt
 
The images 1,2,3 and 4 the smoke goes ok but in image 5 its spawned behind the background layer, if i spawn another smoke its works in the same way.
 

Attachments

  • bor - 0003b.png
    bor - 0003b.png
    14.6 KB · Views: 10
  • bor - 0004b.png
    bor - 0004b.png
    16.3 KB · Views: 8
  • bor - 0005b.png
    bor - 0005b.png
    20.8 KB · Views: 6
  • bor - 0006b.png
    bor - 0006b.png
    19.7 KB · Views: 9
  • bor - 0007b.png
    bor - 0007b.png
    21.5 KB · Views: 9
Hmmm... do you place an entity in front of 5th smoke? that entity might be covering the smoke.
Also, giving setlayer to smoke might help enforcing its layer position.
 
No, in front of 5th smoke is only the panel ,there is no another entity , all others smokes just spawn correct some layer above the panel, but the 5th doesnt.
What could be the correct setlayer value to give to all smoke to be spawned ?
I made a smoke2 entity with set layer 950 just to test and its looks like work, but i had to create anothe entity, i would like to use just one entity to make a better manegement of mamory for consoles versions of my game.
 
I made a test here and i could see that when i spawn the smoke entity, dont metter the X position, if the Y position is less than 131 the smoke is spawned behind the panel layer, if the value is more than 131 pixels there is no problem, the smoke goes in correct layer above the panel.
 
Hey @Bloodbane it works , but with setlayer 1 the other smoke spawned on the grownd looks always behind the player, with no setlayer player can be in front of the smoke or behind the smoke. Just take a look, the first image show the smoke with set layer 1 thats spawned some layer behind the player, the second image show the smoke with alpha effects in front of player.
 

Attachments

  • bor - 0000.png
    bor - 0000.png
    8.9 KB · Views: 3
  • bor - 0001.png
    bor - 0001.png
    9.5 KB · Views: 3
If you want only one entity as a smoke but with different set layers, you can set it in its separate animations. You could try using this setlayer with script like this:

C:
void layer(int layer){
    void self = getlocalvar("self");
    changeentityproperty(self, "setlayer", layer);
}

Example:
Code:
anim idle # regular idle
@cmd layer 950 # Cover at front
offset 1 8
delay 9
frame .....
frame .....
frame .....

anim follow1 # another smoke for being behind
@cmd layer 1
offset 1 8
delay 9
frame .....
frame .....
frame .....

In level, you set those two here, so one of them needs a spawn script:

Code:
spawn smoke
coords 410 277
at 0

spawn smoke
@script
void main(){
    void actual_entity = getlocalvar("self");
    performattack(actual_entity, openborconstant("ANI_FOLLOW1"));
}
@end_script
coords 878 144
at 0

You can spawn the script with either this:
Code:
performattack(actual_entity, openborconstant("ANI_FOLLOW1"));
Or this:
Code:
changeentityproperty(actual_entity, "animation", openborconstant("ANI_FOLLOW1"));

Just a warning. You cannot change setlayer in level with spawn script like this:

Code:
spawn smoke
@script
void main(){
    void actual_entity = getlocalvar("self");
    changeentityproperty(actual_entity, "setlayer", 10);
}
@end_script
coords 878 144
at 0

It doesn't accept that since it's in the level. You only can change setlayer if it's a model.
 
Last edited:
That's not true, maxman. I've modified entity's setlayer directly with spawnscript like the above and it works as intended.
Hmm. I did test it, but it couldn't work for me at all. Is it because I am/was using one of the old versions? I'll try another build/version to test it.
 
but with setlayer 1 the other smoke spawned on the grownd looks always behind the player, with no setlayer player can be in front of the smoke or behind the smoke.

Hmmm.... okay, I thought you won't be putting smoke there.
So another solution is not to use setlayer at all and instead set smoke not to be affected by gravity with subject_to_gravity 0. Then instead of spawning smoke behind minimum z, spawn smoke within playing field + set altitude to it.
 
Back
Top Bottom