- Home /
Question by
landon47 · May 13, 2013 at 01:07 AM ·
switchcontrollers
How to switch between two controllers?
I am trying to switch between a Boat and FPS Controller. I have cameras that I want to use with each controller and I only want them to be activated if that controller is activated. Can someone show me the script to make this work. Thanks.
Comment
Answer by appearance · May 13, 2013 at 07:16 AM
// Boat.cs
public class Boat : Monobehavior {
/* Assuming that you set these two variables
to relative camera gameobjects...
*/
GameObject FPS_Controller_Cam;
GameObject Boat_Cam;
void OnEnable () {
FPS_Controller_Cam.SetActive (false);
Boat_Cam.SetActive (true);
}
}
// FSPController.cs
public class FPSController : Monobehavior {
/* Assuming that you set these two variables
to relative camera gameobjects...
*/
GameObject FPS_Controller_Cam;
GameObject Boat_Cam;
void OnEnable () {
Boat_Cam.SetActive (false);
FPS_Controller_Cam.SetActive (true);
}
}
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Animation ignores yield and plays next one 1 Answer
Boolean check not referenced correctly from other script 2 Answers
Switching between controllers - why do I have to press spacebar twice before it works? 1 Answer
Waypoints using a Switch... 2 Answers