- Home /
Is it ok to move objects with CharacterControllers not through their CharacterController and without adding a kinematic Rigidbody?
I have enemies in my game that have a CharacterController and a NavMeshAgent component attached. Sometimes I move them myself through their CharacterController, and most of the time I let the NavMeshAgent take over and move them however Unity wrote it to move them (probably directly manipulating the Transform). Should I add a kinematic Rigidbody to these enemies? I know moving static colliders is considered a bad idea, but these are CharacterControllers, they were meant to be moved. But they're not always moved using the methods of the CharacterController, so maybe then it's the same as moving a static collider. I don't know.
Answer by ThomasOr · Jul 21, 2019 at 10:17 PM
True answer
Play around with everything, google and ducks are only sometimes your friend.
Give or take answer section
"If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore. The rigidbody will be under full control of animation or script control by changing transform.position. Kinematic bodies also affect the motion of other rigidbodies through collisions or joints." - From here
In other words, if it aint broke, don't fix it. If your enemies are controlled via relative transformations (meaning is the controller adding to the position, not setting it or adding force each frame), which they probs are, having a kinematic rigidbodies will make no difference, or at least I'd assume, and is therefore pointless. However, if you wanted your enemies to fall off cliffs etc. they you may want to have a rigidbody on them with grav and non-kinematic but this is provided that you've setup collides correctly (which you probs have comment if not and I'll explain more).
Massive tangent and moderately patronising section, plz don't take it badly
You mentioned static collides in your post, kinematic rigidbody is not this. In the top right when you inspect an object you'll see a little static checkbox, if you click the dropdown to the right of that you can see the parameters which you can set to static; when one of these is ticked, say, for example lightmap static, then that will not get updated naturally at runtime. This means that if you had a massive skyscraper with 1 gazillon triangles or a complex city scene with 500 point light sources and wanted to dramatically, and I mean crazily, improve performance you can enable lightmap static (or just all static in these cases) mode so that all of the scene lights, reflections etc. will be baked (btw that's what the Window > Lighting window is for configuring and the static/mixed properties are for on the lights are for) into the objects before you) onto the object. This will help a load (without baking one of my scenes with hundreds of point light sources for realism would run at lower than 10 fps on a good gpu) with larger scenes and whilst the baked objects can't be moved, they still can have shadows cast onto them, cast shadows with new light sources and be lit up by realtime lights.
Rant about crap markdown implementation. This is in no way related to the question or to the author of said question
If anyone sees this who can truly influence answers.unity then please try to push this forward if you want.
It's basic css generation, please, please, please just throw your stuff away and copy the github style, I beg you.
.markdown-preview:not([data-use-github-style])
There you go, start with this.
But seriously, you cant even use the OG ``` or ### and above
Why would you do this to me unity
Unity, plz fix.