Hello so recently I have been making a game and in a part of my game I made a very basic portal. the portal would send me to a different location and would switch cameras. The problem with this is that I made a variable telling if I used the portal or not that way if I go into the portal again it will send me back. For some reason though the script doesnt seem to be changing the bool even though I set it to do so. Everything seems to work right but the (usedPortal) int doesnt seem to change
Script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Portal : ActionItem {
public Vector3 City;
public Vector3 Cave;
public Camera[] cams;
public GameObject player;
public int usedPortal = 0;
private void Start()
{
cams[0].enabled = true;
cams[1].enabled = false;
}
public override void Interact()
{
if(usedPortal == 0)
{
player.transform.position = City;
playerAgent.isStopped = true;
cams[0].enabled = false;
cams[1].enabled = true;
StartCoroutine(walkAgain());
setTrue();
}
if(usedPortal == 1)
{
player.transform.position = Cave;
playerAgent.isStopped = true;
cams[0].enabled = true;
cams[1].enabled = false;
StartCoroutine(walkAgain());
setFalse();
}
}
//Do Later
public IEnumerator walkAgain()
{
yield return new WaitForSeconds(2);
playerAgent.isStopped = false;
}
public IEnumerator setTrue()
{
yield return new WaitForSeconds(1);
usedPortal = +1;
}
public IEnumerator setFalse()
{
yield return new WaitForSeconds(1);
usedPortal = -1;
}
}