Hi all,
I’m trying to switch from third to first person when the player enters a collider and it won’t work.
I have my very simple class on the collider object, calling a method.
public class ventCrouchToggle : MonoBehaviour {
void OnTriggerEnter(Collider other)
{
CamCallToggle.SetToggleVar();
}
}
Then this code should change the cameras whenever I call SetToggleVar() but it won’t.
public class CamCallToggle : MonoBehaviour
{
public static GameObject camFirstPerson; // first person camera
public static GameObject camThirdPerson; // third person camera
public static bool check = true; // New check-variable
void OnAwake()
{
camFirstPerson = GameObject.FindWithTag("CamFirstPerson");
camThirdPerson = GameObject.FindWithTag("MainCamera");
}
public static void SetToggleVar()
{
Debug.Log("check");
check = !check;
ToggleCall();
}
public static void ToggleCall()
{
if (check)
{
camFirstPerson.SetActive(false);
camThirdPerson.SetActive(true);
}
else
{
camFirstPerson.SetActive(true);
camThirdPerson.SetActive(false);
}
}
}
The really annoying thing is that I had this code working replacing the collider with a button press to test the code, but the collider is required to implement my mechanics. Any help?