- Home /
How do I enable/disable certain 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;
}
}
What exactly is the problem? Are the functions called already? If not, are they linked with the responsible button in the inspector? Or do you get any errors or messages in the console?
Could you also maybe share the other 3 scripts? Guess that could help to debug.
Your answer
Follow this Question
Related Questions
How can I re-spawn a script component that has been destroyed? 2 Answers
[ C#] Character Movement based on Camera Direction. 2 Answers
Relative AddForce 0 Answers
First person camera judder with rigidbody based characters 1 Answer
How do I enable/disable scripts?,How do I enable and disable scripts? 0 Answers