public class stopeverythin : MonoBehaviour
{
GameObject player;
Arayuz arayz = new Arayuz();
public void durdur()
{
player = GameObject.FindGameObjectWithTag("Player");
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.m_cursorIsLocked=false;
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.tutorial = true;
player.GetComponent<RigidbodyFirstPersonController>().movementSettings.tutoiral = true;
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.XSensitivity = 0;
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.YSensitivity = 0;
player.GetComponent<Rigidbody>().isKinematic = true;
}
public void baslat()
{
player = GameObject.FindGameObjectWithTag("Player");
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.m_cursorIsLocked = true;
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.tutorial = false;
player.GetComponent<RigidbodyFirstPersonController>().movementSettings.tutoiral = false;
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.XSensitivity = 2;
player.GetComponent<RigidbodyFirstPersonController>().mouseLook.YSensitivity = 2;
player.GetComponent<Rigidbody>().isKinematic = false;
}
}[/cod[QUOTE][/QUOTE]e]```[ICODE][ICODE][ICODE]```[/ICODE][/ICODE][/ICOD```E]```
i have like this script for close/open characters movement, when pause button clicked i stop character movement in another script and unlock cursor lock but i have
Unity StackOverflowException: The requested operation caused a stack overflow. error
this is another script
public class Arayuz : MonoBehaviour
{
public GameObject esc;
public bool tutorial = false;
public GameObject oyunkontrol;
public GameObject envanter;
stopeverythin oyunkontrolscipt = new stopeverythin();
// Start is called before the first frame update
void Start()
{
}
void envanteropen_close()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
if (envanter.GetComponent<Animator>().GetBool("envanteropen") != true)
{
oyunkontrolscipt.durdur();
envanter.GetComponent<Animator>().SetBool("envanteropen", true);
}
else
{
oyunkontrolscipt.baslat();
envanter.GetComponent<Animator>().SetBool("envanteropen", false);
}
}
}
It looks like you are calling the method Baslat recursively so it is just constantly running through it. Try calling it once.
I don’t see where you have recursion, but @davidnibi is almost certainly correct.
If you are just looking to pause the game, why not just set Time.timeScale = 0.0f;
?