Preventing weapons from going through walls

I’m building a small FPS example in Urho and i’m facing the following bug that i also experienced in Unity:

However, i don’t know how to fix it in Urho. Any tips?

(but it is not cool method - shadows from another objets do not drop on weapon)

Similar question is asked with solutions here:

First of all, thanks for the quick replies! :grin:

I’ve checked that thread before, but that solution comes with a bug: when inside a wall, the weapon is shadowed. During gameplay, this is very noticeable. Is there another way of doing this with Urho?

At the moment, I believe, the best method is move gun backward (or to side) when gun collides to objects. This is done in many modern games

Pushing back without IK would look terrible, as if the player was going into aim down the sights. Or am i not understanding correctly?

I do not understand why you need IK here, just move model with hands backward

Because if i just move the weapon model and the arms model along the Z axis, it’s going to look as if it was zooming in and out, not actually moving the arms to avoid collision. The only proper way of doing that is to rotate the elbow bone and also the hand bone, OR some sort of IK to avoid collision. That’s why i chose the camera fix in Unity, easier.

I thought the above thread actually addressses the shadow issue (but perhaps with some caveats) :slight_smile:

What about projection matrix hack for this? Useful thing.

What about projection matrix hack for this? Useful thing.

DepthHack for weapon rendering
no one know how to do it )

You can use custom Render Path command for drawing fps related stuff.
Maybe i implement it later.