Archive 17/01/2023.

Preventing weapons from going through walls

smellymumbler

I’m building a small FPS example in Urho and i’m facing the following bug that i also experienced in Unity: https://www.youtube.com/watch?v=9kekrsZzLG8

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

1vanK

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

jmiller

Similar question is asked with solutions here:

smellymumbler

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?

1vanK

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

smellymumbler

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

1vanK

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

smellymumbler

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.

jmiller

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

HplusDiese

What about projection matrix hack for this? Useful thing.

1vanK

What about projection matrix hack for this? Useful thing.

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

HplusDiese

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