0 votes

I believe I read somewhere that Render Priority isn't implemented yet. Just to make sure and to know if I'm thinking of the right term, let me explain what I'm trying to accomplish:

I'm making a boxing game where the player's character (blue) is in front. To make my life easier when animating the opponents, I want to make sure that their attacks and animations don't clip into the player character. I could accomplish this using forced perspective since the camera doesn't move, but I'm certain there's an easier way to do this.

Like how in first person shooters where the player's hands and weapon never clip into walls or any other asset, I want the player character in my game to always be rendered on top. I've tried changing render priority but that doesn't seem to change anything, and turning on 'no depth test' sort of works, but it makes complex meshes like characters have see-through body parts, so I don't think that's the setting I'm looking for. Turning on 'no depth test' sometimes doesn't change anything at all other than affect the mesh itself.

I'm certain that I'm missing an option that I need to turn on or maybe the solution is something else altogether. Any help that I can get or clarification would be greatly appreciated. Thank you in advance!

enter image description here

in Engine by (23 points)

2 Answers

+1 vote

To prevent models from clipping math and physics is used instead of shaders. Two things are used widely in games.

1.)The first is collision checking, often implemented on a per joint bases, this is an example from Unreal:
enter image description here
Notice how the basic collisions shapes are used together to create a rough simulation of what the model will collide like.

2.)The second thing used is Inverse Kinematics, in Linear Algebra there is a lot of easy ways to implement IK.
Godot has IK for 3D, or at least I noticed a class for it.
This tutorial is for Unreal but explains the concept well:
https://peterlantz3d.wordpress.com/home-2/problem-solving/applying-ik-constraints-in-ue4/

by (1,428 points)

Hey MysteryGM, thanks for the link. I've been meaning to look into IK for games, so I'll be sure to check it out.

Unfortunately, that's not the answer I'm looking for. It's my fault, though, I thought explaining my game would make my question more clear, but I think it just had the opposite effect, so allow me to ask my question once more without all the fluff:

Is there a way to set a 3D asset in Godot so it always appears on top of everything else? If so, how do I go about doing that?

Sorry for the confusion, and thank you again.

A cheat you could use is to flag the shader as transparent, then use the render priority.

If both materials are flagged transparent then the one with the highest render priority is rendered ontop.

+2 votes

Changing drawing order changes the order in which the surface is drawn, but that doesn't mean it will not care about the depth buffer.

Making it ignore the depth buffer won't cut all cases because the object is still drawn with some random order, and when it's not a cube it will indeed cause self-see-through issues anyways, so you need the depth test.

One of the remaining solutions could be to render your model on an offscreen texture (using a Viewport), and draw that on top of the game, so it will really be on top of everything with no visual intersection possible. Though everytime I think about a solution involving viewports (and that happens a lot) I often find out it takes some time to make it work right^^"

There are other ways but I don't see how to do them with the somewhat-fixed rendering pipeline exposed by the engine, like:
- Clearing the depth buffer before rendering the object, or using another depth buffer temporarily
- Using the stencil buffer somehow
- Doing a render-to-texture without having to use a whole Viewport
- Trick the depth by writing to the depth buffer with a shader (see https://github.com/godotengine/godot/pull/22800)

Or simply don't care about clipping since it should be minimal if animations are properly interpolated? In a boxing game I would not expect an animation to always play the same way, it could "bend" so that a "punch" animation can target a defined point in space (3.1 supports blend spaces so you can blend animations to target a moving point so it should not miss or clip too much). This is a bit related to MysteryGM's answer.

by (27,275 points)

Hi Zylann, thank you for your help. I had thought that what I was inquiring about was much simpler to accomplish than it was and all I needed was to tick the right checkboxes, but it helps to know that it's much more involved than that. This is fine, because I have workarounds to achieve the result I'm looking for, and this will be handy to know for the future. Again, thank you and MysteryGM for all your help!

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 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.

Categories