Player Is able to rotate through walls.

So, My player Is set up so he kinda “bows” when he looks down, While “bowing” really fast and moving forward against a wall my player is able to glitch through the said wall, I am using “transform.eulerAngles” on the body (In fixedUpdate), I believe rotating the body through a rigidbody would work better but It seems having a rigidbody in any form as a child of another rigidbody (, The player GameObject) seems to just make It spazz out.

Things I have tried:

  • Making every collider convex.
  • Adding a sphere collider to the head.
  • Slowing movement and rotation (/ “bowing”) speed based on distance to wall.
  • Clamping the maximum speed of rotation/“bow”.

All of these seem to work pretty well together, But my player still spazzes out a lot so what I’m asking Is If there Is any “proper”/simpler way to achieve my goal?

alt text

Thank you for taking the time to read this :slight_smile:

(Thank you @seandolan, Don’t know how I missed it), So I managed to get It working amazingly with by using “OnCollisionStay” and “OnCollisionExit” to toggle a bool to disable then enable downwards camera (/ body) movement.

aha! this is an age old physics problem.
Easy solution… not perfect.
simplest one is to use one big bounding box/capsule/sphere that surrounds the player even when at maximum bow.

Lots of FPS shooters , have this problem also. (weapon passes through wall when character rotates) Their solution is to collide the body/capsule… and collide the gun separately and move the gun backwards along a vector along its length until not colliding any longer with the wall.

you could do this by having secondary collision during lateUpdate. after collision has finished. (detach collider and rigidbody from your character head)
The 2 points come from a single node in character head, the 2 points are before and after character move, animation and collision.
Then you do a SphereCast, from old to new position. (just like a raycast, but use a sphere of radius of the head)
This will tell you if the head collided with anything as result of move. and will also tell you how far head moved before reaching collision… and/or how far you’d have to move it back to get it back out of collision…
At this point you have a couple of options… move the whole object back along the before->after vector… by the distance required to move the sphere out of the collision. just rotate or move the head back… or stop just any further bending forward (might be tricky) (or move it back to last valid bend angle)
good luck
take 2 world points