0 votes

I have tried setzindex() in code, and just setting the default zindex at the root of each individual scene which I will be instancing, on the assumption they will be instanced with that zindex.

But when my dagger node spawns an animated sprite (toonSmoke) with a z-index of 500 for the smoke, and 1000 for the dagger-the smoke always appears above the dagger.

if overlaps_target == true:
        audioKnifeHit.play()

        var smoke:Node2D = resSmoke.instance()  
        smoke.position = self.position

        game.add_child(smoke)   
        smoke.play()
        print("Dagger Z-Index: " + str(self.z_index))
        print("Smoke Z-Index: " + str(smoke.z_index))
        call_deferred("reparent_to_target",self, target)
        call_deferred("reparent_to_target",smoke, target)

my console outputs:

Dagger Z-Index: 1000
Smoke Z-Index: 500

But my smoke is above my dagger:

enter image description here

It seems to just order them in scene tree order, and doesn’t care about zindex.

in Engine by (43 points)
edited by

With the information you provided it's hardly possible to help you out. Can you upload an example project (as minimal as possible!) with the problem at hand?

1 Answer

0 votes

The sprite sub node had a separate higher z-Index...my fault

by (43 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.