So I’ve got a problem I’m getting this compiler error in unity saying “Cannot convert ‘boolean’ to ‘Player_Controller’.” and I don’t know why? I’m trying to create a toggle scripts script that accesses two java scripts in the same object that this script is attached to. One is called “Free_Look” and the other is called “Player_Controller”, both are java scripts so I don’t have to worry about calling a C# script. Script below. Sorry if the script sucks I’m not a good programmer just trying to learn problem by problem.
var toggle : boolean = false;
var script1 : Free_Look;
var script2 : Player_Controller;
function Start() {
script2 = GetComponent(Player_Controller).enabled = true;
rigidbody.useGravity = true;
script1 = GetComponent(Free_Look).enabled = false;
Time.timeScale = 1;
}
function Update() {
if (Input.GetKeyDown("f")) {
toggle = !toggle;
if (toggle) {
print("Toggled ON");
script1 = GetComponent(Free_Look).enabled = true;
script2 = GetComponent(Player_Controller).enabled = false;
rigidbody.useGravity = false;
Time.timeScale = 0.5;
}
else {
print("Toggled OFF");
script2 = GetComponent(Player_Controller).enabled = true;
rigidbody.useGravity = true;
Script1 = GetComponent(Free_Look).enabled = false;
Time.timeScale = 1;
}
}
}