Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.
How do I…
Change the elevation of an animated sprite when using the 3D update?
What is the expected result
I am using 3D box to create walls and door, while the player and enemies are displayed as 2D sprites, I am looking at being able to change the elevation of sprites so that they react properly to the 3D environment
What is the actual result
I currently have lights for the doors which I want to be situated at the top of the walls either side, but they sit at the bottom instead, which looks and behaves oddly.
Related screenshots
![Desktop Screenshot 2023.05.19 - 15.02.46.43](https://forum.gdevelop.io/uploads/default/original/3X/f/9/f92d157262f76e63ce46460d041f99455f29fc26.png)
BTW, it’s fine for the lights to behave display in 2D, I’m just looking at a way to get them to react to the wall at a higher level, I hope this makes sense.
If you want the light to be higher, try increasing the z order, that is what works for me
Using ‘Z order’ only decides which of the items is displayed on top (In the same layer), not the height in relevance to the 3D walls themselves.
I can create a new 3D box object and only display the FRONT texture, this works for height because it gives me an elevation option in it’s settings, but unfortunately I cannot animate a 3D box object so it will not work in this case, as my lights are animated.
Oooooohhhh, I think I get what you’re saying. When i made my 3d game, i was using pandako’s 3d extension, and i was using the 3d object behavior, and you could raise and lower an object via z order, however, if your using actions to create them, i have no idea how to do this, sorry
1 Like
I hope that the option for selecting a sprites elevation is something that the developers will look into, in the meantime I have found a workaround for my particular problem that others may find useful…
Rather than rely on animated sprites for my door lights, which would change animation and thus colour from red to green when the player is in possession of a key and collides with the door,
I have opted for another solution…
Creating a 3D box item for the light I was able to display only the front texture with the red light sprite on it (Transparency enabled), this behaves correctly with the 3D motion when set at the correct height.
I then created a variable for the Red light, (0 =Locked 1 = Open) and made an action which changes the ‘Front’ texture to the Green light sprite when unlocking with a key.
There is no animation as such, but for the purpose of my door light an instantaneous switch of colour adequately suffices.
The next problem I had was that, in my original 2D version I had a lighting effect displayed over the light which would change the colour of the glow around it, however just like the sprite, this could not be displayed at the correct elevation to work with the 3D effect correctly.
My workaround here was to create another 3D box object and this time retexturing ‘Front’ with a PNG file that I created using Photoshop and a soft brush, setting the opacity to 50% before saving.
In the actions, this changes from red to green the same as the light sprite.
It’s not the most elegant solution, but it works for now…
I hope that this helps others facing similar issues.
1 Like
One thing I’ve found playing around with the 3D is that while you can’t raise the Z position of your 2D elements, you can lower the z position of your 3D elements. So rather than raising your sprite 10 units, lower your door and floor by ten. Sprites seem to sit around Z=0
2 Likes
You’re right that setting a minus Z order will place the wall lower than the 2D sprites, so long as they are on the same layer and would work fine for a platform game with a distant background or at least a background that is not meant to be connected the the bottom of the walls, however, since my floor sits at Z0 and needs look visually connected for texture purposes, it doesn’t work for my top down game as either…
If both floor and wall on the same layer, the floor shows halfway along the wall, but the wall then goes through the floor with the back half not visible behind it…
Or
If the floor is on a layer underneath the walls layer, then it moves at a different speed to both the wall and player so doesn’t act visually connected.
The only way that I can see it working using that method would be to make the whole floor a 3D box item and set the Z order of it to match the bottom for the walls, however I’m not sure how this would work with performance, I am trying to minimise the use of 3D box items where possible for this reason.
How do you change the z order of a 3d box? I am not talking about z elevation, this can be done in the editor, but there is no option to change the z order. This, while in the editor hovering over a 3d object does display the z order in the popup menu.
Also, when changing the z order through events, it doesnt have any effect on which item is displayed on top.