Preventing weapons from going through walls


#1

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?


#2

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


#3

Similar question is asked with solutions here:


#4

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?


#5

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


#6

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


#7

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


#8

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.


#9

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


#10

What about projection matrix hack for this? Useful thing.


#11

What about projection matrix hack for this? Useful thing.

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


#12

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