0 votes

I am wondering how can I make it so all units that are position.y above building they are rendered behind it, and if their position is below the building then they rendered above it...

Let me know if you can't understand the question and need images...

Currently I try following, but it does not do anything and even if it did I imagine it would be quite taxing ?

func _process(_delta):
for i in get_children():
    if i.has_method("look_at"):
        if i.global_position.y < $Building.global_position.y:
            i.z_index = -1
            i.z_index = 3
in Engine by (87 points)

1 Answer

0 votes
Best answer

You're looking for a YSort node.

by (7,792 points)
selected by

Thanks, I look into it!

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 webmaster@godotengine.org with your username.