+1 vote

I have the following setup and am trying to work out a way to have each Viewport display a different z_index for each sprite. Is there an easy way to do this?


I have tried using YSort but it applies the sorting to both Viewports.

To clarify what I am trying to do is to get the left Viewport to display the blue Sprite drawn on top of the red Sprite and the right Viewport to display the red Sprite on top of the blue Sprite.

The use case for this is where each player would see their own character sprite in the foreground in a split-screen side-scrolling game where the players are collision exceptions with each other.

Godot version v3.3.3.stable.official
in Engine by (13 points)

1 Answer

0 votes

A brute-force solution I can think of is:
1. In Viewport 2, add another Sprite that's FakePlayer2
2. Viewport 2's FakePlayer2 tracks the position of the real player 2 in World.
3. Set FakePlayer2's z-index to a high value.

This essentially achieves your goal.

by (14 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.