Question by
subhash147 · Sep 03, 2016 at 05:47 PM ·
objectsceneglobal variableglobal variables
How to use objects differently between scenes?
Blockquote
I am using a bar(rigidbody2d) in two scenes ,in one of the scenes it will be stationary and in the other it will be moving. My concern is that in the script i have set it stationary now,if i move it ,will it not be moving in both the scenes since i will be doing that in the update function?...how do i tackle this?
Comment
There are several was you could approach this. But since it is a script that you are unsing in more than one scene you can do something like this
public bool barIsStationary = false;
private Rigidbody2D rigidbody2D;
void Start()
{
rigidbody2D = GetComponent<Rigidbody2D>();
}
void Update()
{
if (!barIsStationary)
{
$$anonymous$$oveBar();
}
}
void $$anonymous$$oveBar()
{
// perform movement
}
In the script for each scene set the barIsStationary property appropriately.