- Home /
configure first person controller at runtime
What is the best way to configure a first person controller at runtime/startup based on Application.platform? Specifically I'd like to use the "Standard Assets > First Person Controller" if the user is on a Desktop platform, and the "Standard Assets (Mobile) > First Person Tilt Controls" for mobile platforms, but I might also have a third platform to support (Oculus Rift), so I want to try to keep it flexible.
I've gone down the road of adding both controllers to the hierarchy and only enabling the desired one based on platform, but this seems very clumsy since it means that any changes we want to make to the camera in the editor have to be made to the cameras in all controllers.
But if there is only one camera in the scene, the only solution I can think of is to add all of the required components and parents to the camera programmatically, which seems equally painful. It would take dozens of lines of code and would also limit our ability to make changes in the editor.
I've also looked in the asset store but haven't found any packages that seem to tackle the cross-platform issue well.
Is the solution to have prefabs that I can just instantiate based on platform and then insert the camera into at runtime? Or perhaps it's a lost cause and I should just reconfigure manually before building?
Thanks!
The last bit about using prefab is how I would probably approach it.