- Home /
How to switch between FPSController controlled camera and fixed camera
Hello, I am using FPSController from Unity standard assets.
Sometimes I need to switch from FPS mode to drawing mode, in which I use my mouse to draw lines on the screen.
I tried the following code in Update()
:
if (state == States.Drawing) {
if (Crosshair != null) Crosshair.SetActive(false);
if (fpsController != null) fpsController.enabled = false;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else {
if (Crosshair != null) Crosshair.SetActive(true);
if (fpsController != null) fpsController.enabled = true;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
Where fpsController is the reference to the FPSController component.
When I enter drawing mode, my mouse is released, but after a click ,it's captured again and the fpsController is still working. I suspect that fpsController.enabled = false
is not working at all.
Is there better way to do this?
Answer by gordiri · Jan 24, 2018 at 10:00 AM
fpsController.enabled = false
should work. Are you sure that fpsController reference is not null?
Your answer
Follow this Question
Related Questions
Error Transferring Unity 5's FPSController to Unity 4.6 1 Answer
I have a question regarding the mouse look on the FPS controller. 0 Answers
I have an issue when I go to play my game (screen has a gradient can't see scene) 0 Answers
How can you prevent slowing down if you look up/down while using FPS controller? 1 Answer
My FPS controller slides forward/left but only in the build. Why? 0 Answers