The idea for this script is that when the player interacts with a door his controls will be paused and he will be teleported to the other side and he will be able to move once again.
I am using coroutine so that he also isn’t able to spam the door teleport which works but the player controller still moves.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SUPERCharacter;
public class Door : MonoBehaviour, IInteractable
{
public SUPERCharacterAIO playerScript;
public AudioSource[] BUZZ;
public Transform player, destination;
public GameObject playerg;
private bool isInteracting;
public bool Interact()
{
if (isInteracting) return false;
if (playerScript.enableMovementControl) return false;
isInteracting = true;
playerScript.enableMovementControl = true;
StartCoroutine(enterRoom(1));
return true;
}
private IEnumerator enterRoom(float delay)
{
yield return new WaitForSeconds(delay);
playerg.SetActive(false);
player.position = destination.position;
playerg.SetActive(true);
isInteracting = false;
playerScript.enableMovementControl = false;
}
}
As you can see I am trying to call the bool from the player script which is the main problem for me.
How do I fix this so that it works?