GavynBryan / Anomie

FPS Game made in Unity3D
0 stars 0 forks source link

Fix bug where player fires on themself #43

Open GavynBryan opened 1 year ago

GavynBryan commented 1 year ago

When jumping, moving forward and looking down at the same time, the player's weapon behavior will clip into its own collider. Find out why this is happening and resolve.

GavynBryan commented 1 year ago

This confuses me since to my knowledge a raycast (or even a spherecast) is supposed to ignore the collider it starts in. And the origin is always going to be the camera which is a child to the player object.

I'll get to this once I'm done with Base AI behaviour, but here's my plan so I don't forget:

My worst fear is that somehow the player's position at a given frame is lagging behind their velocity or something similar.

GavynBryan commented 1 year ago

This is also somewhat challenging to reproduce since the rays fire at somewhat random angles and I can't get this to occur with every shot.

GavynBryan commented 1 year ago

This is an issue with the CharacterController's Move() function being called in Update() instead of FixedUpdate(). Unity's colliders only update in Physics updates so it makes sense that sudden changes in velocity like jumping would cause issues with raycast origins not being accurate.

I believe this will resolve itself in #31