- Home /
Better way to swap player controller scripts?
So in my game, I have multiple player controllers that control the player character differently. They are all components of one player object. Currently, I have it set up that when the player enters specific triggers, the current controller script is disabled and the selected one is enabled. This seemed to work well for a long while, but now I'm starting to think this isn't a very solid method.
When switching controllers, it feels like the disabled controller is still running for a bit. The issue only became apparent when the player died and respawned inside of a controller_switch trigger. Even though the new controller is successfully enabled, it seems the disabled controller is still finishing up and executing its respawn function and this leads to messed up player controls.
I keep adding more and more bandaids for this switching process and it's getting cumbersome. So now I'm wondering if I should be looking at alternative ways to handle switching controllers. Perhaps disabling and enabling controllers isn't a very effective method.
Your answer
Follow this Question
Related Questions
How to enable and disable a child collider in an animation 1 Answer
Enable collider then disable it after a certain amount of time 1 Answer
physics.OverlapSphere colliders 1 Answer
Keeping Character Grounded 0 Answers
How can you get the colliders of an object to only be at the edges of the object? 1 Answer