- Home /
collider not collidinng with bottom of object
I am making a third person shooter, currently i have a simple player model with a rigid body and collider attached and when i run into the bottom of a wall (the wall is hovering at aprox 0.8 of the height of the model) it does not collide with it it rather goes through it (I am using rb.MovePosition() ), but if its a little lower it collides (the wall has only a box collider)
collider:
result:
as you can see the player collider does not collide with the floating cube, but if i lowered it by just a little it would have collided (cant upload more than 2 images).
P.S excuse me for any errors I have brought upon the.
Answer by TobiasAndrion · Jul 16, 2016 at 06:53 AM
I read the page on rigidbody.moveposition. It says that if your object has isKinematic set to false, the function works like transform.position = newposition. That is probably the source of your problem, as your player has isKinematic set to false in your screen shot. My guess is because it is basically teleporting your rigidbody forward a little bit every frame, it is somehow ignoring the minor collision of the surface grazing your head. api page on rigidbody.moveposition()
Have you tried simply turning kinematic on and seeing if everything still works as intended? I'm not sure if that would simply introduce more problems but it is a place to start.
Also, what if you added a small extra collider above the main one that only interacted with environment and not any of the damaging elements of the game? It might be able to convince unity that you are in fact ram$$anonymous$$g into a wall and stop you all the same. That particular solution seems janky, but might be a good enough fix for your purposes. Or another-nother solution may be to use a box collider ins$$anonymous$$d of a capsule?
Well....lets say...it didn't work even the slightest, but i think I'm going to try using physics forces ins$$anonymous$$d of $$anonymous$$ovePosition, AddForce with velocity change might work