- Home /
How do I enable/disable scripts?,How do I enable and disable scripts?
I'm fairly new to unity so I might just be missing something obvious, but I'm trying to make a menu in which you can change the pov of the character with a click of a button. I've tried and tried, and searched through google and youtube, but it just doesn't seem to work for me.
When I press a button, it's supposed to enable/disable a specific script on the main camera that allows the camera to see through the pov I just chose, but whatever I try, I just cant seem to get it to work. Here's my code:
using UnityEngine;
public class CameraMenu : MonoBehaviour
{
public FPS FPS;
public ThirdPerson thirdPerson;
public Person2view person2View;
public void FP()
{
FPS.enabled = true;
thirdPerson.enabled = false;
person2View.enabled = false;
}
public void SP()
{
FPS.enabled = false;
thirdPerson.enabled = false;
person2View.enabled = true;
}
public void TP()
{
FPS.enabled = false;
thirdPerson.enabled = true;
person2View.enabled = false;
}
}
Thanks
,I'm trying to make an options menu that changes the POV of the player. When I press the "First Person" button, it should enable the first person script on the camera, but it doesn't. Would anyone be able to help? Here's my code
using UnityEngine; public class CameraMenu : MonoBehaviour { public FPS FPS; public ThirdPerson thirdPerson; public Person2view person2View; public void FP() { FPS.enabled = true; thirdPerson.enabled = false; person2View.enabled = false; } public void SP() { FPS.enabled = false; thirdPerson.enabled = false; person2View.enabled = true; } public void TP() { FPS.enabled = false; thirdPerson.enabled = true; person2View.enabled = false; } }