- Home /
Is moving a collider without rigidbody bad?
Hi,
I have a problem which I asked about here and still didn't get a solution.
The summary of the problem is this: When the player with a character controller, and an enemy with kinematic rigidbody and a capsule collider on it crash into each other, the player just hops over the enemy. It's the problem of colliding the character controller and a kinematic rigidbody which seems to have been around quite a while and it baffles me that there's still no solution for this, as it seems to be pretty central to character controller interaction.
My question here however is whether moving a static collider (without rigidbody) still causes the whole level geometry to redraw its colliders? Because I've removed the kinematic rigidbody from my enemies, and they work well with only colliders on them (no hopping). I tried profiling the game with 20+ enemies and couldn't see any performance drop in the profiler.
So now i'm not sure if I even need to find a solution for the original problem that I had.
Is it still bad to move a collider without a rigidbody on or did Unity do something about it that I don't know?
Answer by jackhearts · Mar 27, 2017 at 08:10 PM
As from Unity 5 the physics world isn't redrawn when using the 3D (PhysX) engine to move a static collider (no rigidbody). However it is still redrawn for 2D colliders (Box2D) so if working with 2D physics make sure a rigidbody is attached. As far as I'm aware this is still the case but to be sure the profiler 'should' throw up a warning if you're moving a static collider and shouldn't be.
Do you have a source for this? AFAI$$anonymous$$, all dynamic physics objects should have a rigidbody on them.
Yeah I remember Profiler would throw in capital letters something like "RECALCULATE PHYSICS", which meant you were causing it to redraw physics, but in this case it's not throwing anything like that and in general stays at very good performance even with 20+ of those enemies; so I guess something must be working right.
But as tanoshimi said, could you double check somehow? Would be great to be 100% sure, just so I can move on with this problem and not worry about it further down the line.
@tanoshimi @Bigproblem01 - here's some links. It's someone from unity making the comment so I'd take it as solid. Whether the Box2D implementation has also changed since then I'm not sure. There's a comment mid 2016 that indicates it hasn't. If the profiler isn't showing much of a hit then go with what works though. Worth noting he says the penalty is reduced, not necessarily removed, so I'd be inclined to use a kinematic rb regardless.
Is the penalty for moving a collider without rigidbody much higher on 5.3
Unity 5: RigidBody or No RigidBody
On a side note to your original problem. The character controller isn't really meant for rigidbody physics interactions so you either have to detect and deal with them yourself in script using OnControllerColliderHit() or switch to using a rigidbody for your character. That's why your were having problems.
Thanks a lot jackhearts. I'm using character controller because UFPS has it and I'd like to use its other functionality, so switching to rigidbody wasn't really the best option for me, and all the workarounds using OnControllerColliderHit() seemed hacky and didn't work very smoothly, so I'm happy I can just use colliders without rigidbodies (at least for now the profiler seems completely fine with it, hope it stays that way :D )