- Home /
Character Controller collision disabled after some time
I'm working on a game with third person view. The player character movements and collisions are controlled by a Character Controller. Everything work fine. But after some time, the collision detection on the Character Controller seems to deactivate by itself and the player character fall through the ground are through the walls. This only happends when I use a LootAt function of me own wich does several RotateAround calls on various bones. If the RotateAround calls (and only the RotateAround) are commentented the problem does not appear. I dont see how the collision detection problem can be linked to te RotateAround method. Any help to solve this mystery would be greatly appreciated.
Basically, using Transform to move things ignores physics/collision, so using RotateAround would allow the object to pass through the floor, and once it's through the surface, it will fall right through.
You would want to find a different method for whatever you are doing in your LookAt function
Please, re-read what I wrote, I think you didn't really understand what I said. Or my enslish is worth than I expected, in this case, I'm sorry.
In no way the Cahracter Controller is linked to the skeleton hierarchy. The Character Controller is only linked to the GameObject by it's root transform. If what you say would be true, we shouldn't be able to animate objects using Character Controller without causing severe problems. What is weird is that the collision works for some time before disabling itself.
I get what your saying they are DIRECTLY connected HOWEVER they are indirectly. They are both children of the playerobject.
The problem is the Collider is a box drawn around the point in space that is the center of the game object it's attached to, but somehow it appears while rotating you are moving the center point which the collider is drawn off of down slightly during rotation.
This is what you could do to try and help debug.
disable gravity.
output the gameobject position before the rotate call output it during each update of the rotate output it at the end
now rotate a whole bunch of times is all sorts of ways.
Somewhere along the line your code is causing the object to move.
Look in your code for any reference to the parent position.
Lets say for example you have a gameobject mesh and it's 2 meters tall the center would be that point 1 meter below the top, the mesh would go from the tip of the players head to the sole of the foot. If you take the foot and you rotate that foot bone to point down, now all you did was rotate the bone right? But wait, that bone moved the player mesh, now by rotating that bone from a 90 degree angle to a 0 degree angle you have made the whole mesh longer. it's now a 2 meter and 1 inch long mesh.
The center of the object is now 1 meter 1/2 inch from the top the collision box is drawn from the center so now the collison box has moved because the center of the object it is drawn off of has moved because of the bone movement.
Your answer
Follow this Question
Related Questions
Help in Javascript destroying Objects using character controllers and conditionals 1 Answer
Moving 'platforms' not colliding with you 1 Answer
Collision update speed 0 Answers
CharacterController Collision causing teleportation? 1 Answer
Character controller, player y changes when pushing on colliders 1 Answer