Are Character controllers cpu hungry?

Hi,

I would like to have aoround 4 or 5 enemies on the screen + the player. I have thought about implementing all of them with character controllers. Is this too mucho fo rthe iphone? Don’t really know how much cpu power does a character controller need.

Thanks in advance,
HexDump.

I have a bit of an interest in this as well. Right now I only use it for the player and at this point that’s all I planned to use it for. Is it better to not use the character controller at all?

In my experience they don’t have a significant effect on performance, I’ve been using character controllers for my enemies which I have tested as many as 6 at a time without major performance loss (and they’ve been doing plenty of bumping into each other). I think any added draw calls and AI scripts running will have a far greater impact than the volume of colliders.

Thanks for the answer :).

HexDump.

I would say they don’t hurt, until they collide with something.

In a game which I’m not allowed to show screenshots of yet (cries), I spawn a few enemies without issue. Framerate stays around 50 or so on an iPod touch gen 2, but the moment they bump against a collider, its DEATH.

How bad can this death be, you ask?

Frame rate can drop to 20… Which on the iPhone 3G worked out to about 10fps.

So my answer (I admit its really only based on that one project is)… If you expect them to be bouncing off walls or something, don’t do it… You’ll cry :slight_smile:

… If anyone suspects I’ve done something hideously wrong, let me know :stuck_out_tongue:

Well as PirateNinja said he has had around 6 characters on screen with collisions and he has had no issues. So I’m pretty confident it will work, but I’m sure there will have to be some sort of mods to get it to work smoothly. I wasn’t planning on using the character controller for my enemies, but I think I will try it first just to see what happens.

Yeah, my game doesn’t have constant collision going on - it takes place in some fairly primitive arenas, with a small number of box colliders ringing in my characters. The ground is always “flat” in my game, so I have no collider for the ground plane either. The AI does walk into each other from time to time but this has no pronounced effect on performance in my case.

JT - are your character colliders interacting with their environment when your FPS dies, or just each other? Are you using mesh colliders for your environment? Are you running any scripts that trigger other actions upon collision (like, play a sound effect on contact with another collider or something)?

When they bunch together, the frame takes a slight hit (not a big deal). Its when they collide with box colliders on scene geometry (I avoid using mesh colliders wherever possible) that it all gets too hard.

And no, I was not triggering any collision activities, etc.

This is a bit of a pain JTBentley is right :(. Any other solution to this?

Thanks in advance,
HexDump.

That app (which is delayed while i work on more pressing applications) has had some saving graces. I’ve basically removed all physics and characters controllers in favor of a giant controller script I made in java that handles all of it.

This makes it a bit slower to work with and tweak, but my frame rate issues have vanished.

In hindsight, rather than dumping character controllers altogether like I did, I simply should have made the AI avoid bumping into geometry to begin with. This could have been done either with a repellant object or a waypoint system.

Meh :slight_smile:

Just as an experiment, I loaded up a test level with a few AI guys and through in a ton of junk for them to run into. I can certainly verify that the performance hit is pretty huge when you have several character colliders rubbing against box colliders/each other every frame. Like JT suggested, the optimal path would be to keep your AI from constantly colliding with things rather than dump character controllers altogether, but there’s clearly some overhead in Unity’s collision system to work around.