Why my framerate fall down to 5-6FPS once I use CharacterController.Move()

I need to make several enemies (AI) move.

Once I use CharacterController.Move() or CharacterController.SimpleMove(), the framerate would gradually fall down to 5-6FPS (SimpleMove() would be a little better, but still not acceptable).

But if I simply use Transform.Translate(), the enemies would not be able to climb/descend along the terrain. They would rather penetrate into the terrain.

So anyone could help me find out a way out of this issue?

There must be something wrong - the CharacterControllers would slow down Unity this way only if you had an entire enemy army! I bet on some coroutine being continuously called in your AI - this creates an always increasing number of coroutines running in parallel, which gradually slows down your game.

Post your AI script - only analyzing it we can help you to find the culprit.

Just an overview here:

myTransform.animation.Play("run");

You are doing this every update. Is the animation shorter than an update cycle? Is the 'run' cycle really necessary this quickly?

If the animation is several frames then you want to call this at a slower rate.

Hope I called this correctly.

put a Debug.Log() in each if and else statement. The maniac activity should show up in the console. If it doesn't then you got bigger problems than Answers.unity.

I finally got it!!!After one whole day work,at last!!!

It’s all about the setting of my CharacterController. I used to set it too large in Height,Radius,…all other parameters, because my model imported is big.

And then I changed all of these stuff back into the values suggested in the official Reference page. And the FPS now is 80+ for 10 enemies!

Oh yeah!!

+1 for changing the radius of the capsule. I only have one enemy in the scene, and the CharacterController only gets called if the Player is too close. The only things in the function are transform.LookAt (player) and SimpleMove (direction*Speed).
Changing the radius of the CharacterController from 0.02 to 0.01 solves my slowdown issue (that only happens when you get too close to the NPC, and the chase function is called)
HTH
Ian

I had a similar problem where Move and SimpleMove were taking a lot of CPU. I finally tracked it down to setting transform.localScale every frame (usually to the same value), which I’m guessing did something to make the CharacterController do a lot of work.