Hey, so the game I am making is a multiplayer game where you and other players will be running around in an environment and be able to throw items (just a few spheres). Each player is using their own instance of the CharacterController class from the most recent demo to handle movement and physical interaction. Everything is fine and dandy with a single player where I get 60 FPS. If I add 4 players and all they are just standing in the spot I spawned them at, the game starts to struggle with 55 - 60 FPS. If all four players start touching or interacting with each other, the game's FPS goes down to 20-25. I dont even want to think about what the game will do if they are all touching and throwing things. Note that it only has this much issue on the Xbox. When I run the game on my computer, I get 60 FPS regardless.
I have already added multiple threads with this:
space.ThreadManager.AddThread(information => Thread.CurrentThread.SetProcessorAffinity(new[] { 1 }), null);
space.ThreadManager.AddThread(information => Thread.CurrentThread.SetProcessorAffinity(new[] { 3 }), null);
space.ThreadManager.AddThread(information => Thread.CurrentThread.SetProcessorAffinity(new[] { 5 }), null);
space.UseMultithreadedUpdate = true;
and I dont know that it is important, but this is the constructor I use for the CharacterController class for each player:
physicalCharacter = new CharacterController(Vector3.Zero, 4.5f, 2f, 100f, .9f, .01f, .04f);
Is there anything else I can do to help speed this game up?
Multiple CharacterControllers On Xbox
Re: Multiple CharacterControllers On Xbox
The Xbox360 should be able to handle way more than 4 full CharacterControllers. I tried a quick test with a bunch of them on a box using the default settings and had dozens working at above 60 fps. A "real" environment with more interactions will increase the cost some, but 4 is way too few.
Note that by default, the CharacterControllers will not multithread since Updateables default to updating sequentially for simplicity. Try setting the CharacterController's IsUpdatingSequentially to false. Since the character controller, by default, does not apply forces or changes to anything other than itself, it can be safely multithreaded without additional locks or worry. You'd have to add in some precautions to prevent race conditions if you wanted to apply forces to things being stood on, though. With multithreading enabled, my Xbox360 is running well over a hundred character controllers standing around at 60 fps.
The performance problem is likely sneaking in from somewhere else. I would recommend profiling it to check for non-physics hotspots and also investigate any physics usage hotspots which seem unreasonable. Those areas will probably contain some shenanigans which could explain the performance loss. Analyze the environment to make sure there aren't any strange things like hyper-tessellated meshes that are generating hundreds of pointless collision pairs.
Note that by default, the CharacterControllers will not multithread since Updateables default to updating sequentially for simplicity. Try setting the CharacterController's IsUpdatingSequentially to false. Since the character controller, by default, does not apply forces or changes to anything other than itself, it can be safely multithreaded without additional locks or worry. You'd have to add in some precautions to prevent race conditions if you wanted to apply forces to things being stood on, though. With multithreading enabled, my Xbox360 is running well over a hundred character controllers standing around at 60 fps.
The performance problem is likely sneaking in from somewhere else. I would recommend profiling it to check for non-physics hotspots and also investigate any physics usage hotspots which seem unreasonable. Those areas will probably contain some shenanigans which could explain the performance loss. Analyze the environment to make sure there aren't any strange things like hyper-tessellated meshes that are generating hundreds of pointless collision pairs.
Re: Multiple CharacterControllers On Xbox
I tried setting the IsUpdatingSequentially to false, and that did help some. I also noticed that I had turned space.SimulationSettings.CollisionResponse.Iterations to 50 and turning that down to 5 seemed to help a lot. Thanks for your help!