Moving variables through diffrent scripts.

heres my issue.

i am making a game that changes frames when the player gets close to the edge of the screenbox. it does this seemlessly. the player script has a trigger function telling the screenbox when to move with it. however i cant comunicate with the screenbox and tell it when to move.

i have tried

GameObject.find(“Object”).GetComponent();

and also making a static variable, and trying to assign it to a diffrent variable in another script.
but none of these seem to work. i know this is a noob question and i probobly should know this by now.

(side note i dont ask people stuff like this unless i cant find anything on google.
or im just dumb enough not to find anything on google)

The general term for what you’re looking for is a “game manager.” This is a script that is generally available from scene to scene, or for the length of the game, or some “longer-than-usual” period of time.

It’s not uncommon for a game to have several managers to allow continuity:

  • game level manager
  • game audio manager
  • game world manager

etc.

There are a bunch of ways to cause something to hang around a long time like this, so work through a couple of tutorials on either “game managers” or “singletons” or such longer-lived things.

ok wow you are like. the most helpful person on the internet.this is the… 4th? 5th? time you have answered my question.
thank you for directing me to game managers.

1 Like

Heh, you’re welcome. Remember there’s a lot of different ways to do it, so stick with something simple at first, get the basics you want working, don’t try to combine multiple ways of doing a game manager, because often the different approaches will conflict with one another. Best to work through each tutorial you find separately and try to understand the specific approach used in each tutorial, to get a survey of what is possible.

mhm mhm that is what i tried to do at first when trying to change screens and all the ways i tried conflicted

Hello

In this case you can use an Event too.

Christoph