Godot Version
3.5.1
Question
I’m aiming to work on a Sonic Battle / Little Fighters style of Beat Em Up but with extra platforming. I figured writing 2D with Height/Fake Z-Axis from scratch is going to be hard so I went into 3D with Sprite3D.
Everything is working good so far up until I figured Sorting Issue on Transparency.
So I tried working on 2D World and YSorting is exactly what I was hoping to achieve in 3D.
But now I do need to write Height/Fake Z-Axis in 2D and also deal with properly sorting Sprites depending on the height. I’ve gone past tutorial hell and I know what I want to do but I don’t know what approach at this point.
It seems like the sorting problem you were having in the 3D version should be solvable just by pushing things apart a bit in depth. Make the wall be 0.001 further away from the camera than the grass, and the tree 0.001 further away from the camera than the wall. The distance won’t be far enough to have any visible effect on the scale, but it should make them sort properly.
I can do that in the Background Layers (I can just fix them with Render Priority) but everything in the Main Battle Area like Multiple Characters, Multiple Objects or Multiple Attack Effects should all be sharing the same Render Priority and at some point will be in the same or near Z-Axis, and that’s when it’s going to be a huge pain because they are being rendered incorrectly (as shown in the first video where the player popping above the grass and wall when I just placed the player behind them)
In 2D, they are sorting perfectly and is the only exact outcome I was expecting in 3D.
Disabling the Transparency of the Sprite3Ds is also exactly the kind of sorting that I wanted to achieve in 3D, but of course minus the black background.
As you see here, if I move my character away from the grass, it does show behind, but at some point it will also start showing above the grass, and with this inconsistency, I’m not sure how it will happen in the near future which is why I cannot proceed
The fix in 3D should be to use actual depth; the positions are Vector3
, and the depth position in that is what’s used to sort.
I’m sorry but what Depth Position? “No Depth Test” is the only option I have in Flags.
Not in the flags.
Your 3D objects have position
as a Vector3
. Assuming your camera is looking down the z
axis, x
will be horizontal position on the screen, y
will be vertical position on the screen, and z
will be distance from the camera.
Transparent stuff in 3D is sorted by distance from the camera, and the furthest things are drawn first, so the transparency composites properly.
What I think is happening in your code is you’re setting two of the dimensions in position
and either not setting the third or setting it to 0.0
. That puts everything on the same plane in 3D, which means the sort order is arbitrary.
I wouldn’t rely on Render Priority for this in 3D, I’d use the position
vector.
Blockquote
What I think is happening in your code is you’re setting two of the dimensions in position and either not setting the third or setting it to 0.0. That puts everything on the same plane in 3D, which means the sort order is arbitrary.
I’m sorry, I’m still lost.
I made a code for the Camera to follow the Player’s X and Y Position only.
As for the Player, I coded the player to change X and Z Position with Direction Keys and I use the Y Position for Jumping and Gravity.
And yes, I cannot use Render Priority in the Main Battle Area, I’m only planning on using Render Priority for Background/Foreground layering.