- Home /
Physics not working with Character Controller
So, I'm using a character controller component on my sphere to roam around, yet I can't seem to do collisions correctly. using the RigidBody and Character Controller they don't allow for OnCollisionEnter it seems, but when I add a Collider to it... It starts to breakdance, No clue why, I guess the collider and rigidbody are bouncing off of eachother or something, is their any way to stop this so I can have collisions work the way I want them to? I know there's something like OnCharacterControllerCollision or something, but if you use that and run into something, it registers it as thousands of collisions per second, where was "OnCollisionEnter" Registers as one, which is what I need.
Hi LPGa$$anonymous$$g, as we stated on the other question you made, your system is completely glitched out. But, if you're runing this code on other machine, you also need to tell us about the version because a lot of things changed from Unity3 to Unity3.5 and some of them had to do with Physics. If you're on Unity4, that's weird, because it works on my computer. Check if your GameObject's collider isn't with the "trigger" box checked.
I'm on unity 4, I've been running unity 4 for awhile, I just stated on the other thread that the editor is glitching out. All of my scripts were writtin inside of unity 4, they were workign before. Not sure if you where the one to downvote, but there was absolutely no reason for it. The question is completely unrelated.
I didn't downvote and I also don't see any reason for it. So anyway, your scripts were working before the editor started glitching out and then some of them stopped working?
No, It's been glitching since I installed unity, I reinstalled unity again a few moments ago and it's still doing it. $$anonymous$$y script just stopped working randomly, all of the scripts work, but the collision parts won't do anything.
you need to post code.
You also need to decide whether to use a rigidbody or a character controller. They are both implementations of the physics system.
As to the idea of thousands of times per second that is by definition impossible basically without changing stuff you almost certainly didnt change.
Physics occurs during fixedupate which can be changed in frequency but by default runs at 60FPS. So at most your colliding 60 times per second.
That assumes your continually trying to push through an object in which case yea it has no choice but to constantly run physics simulations to react appropriately.
$$anonymous$$Y GUESS
character controller is a collider by definition. It has one built into it, a capsule shape. Placing another collider onto that with a rigidbody means these two objects are probably directly in collision with eachother AND they can't escape. One object is probably attempting to move EVERY SO SLIGHTLY to stop being in the other objects space. But they are tied together so moving one collider moves the other, they infinitely fight eachother and move slightly and who the hell knows what happens but i imagine it looks alot like breakdancing.
Answer by Loius · Jan 16, 2013 at 07:53 PM
You could attach a duplicate capsule (with kinematic rigidbody) to your controller, on a layer that doesn't collide with the controller itself, and use that object to check for collisions instead of the controller.