- Home /
Expression cannot be assigned to, doing it wrong, but how?
I have two scripts in different .js files and i want to refer to one through the other, i have watched the GUI tutorial by tornadotwins, and i am trying that method to get a guitexture to show when my player collides with a pickup.
Here is the script for PointGet which i want to make the gui appear with
#pragma strict
static private var onPoint : boolean = false;
function FixedUpdate () {
if(onPoint == true){
guiTexture.color.a = 255;
yield WaitForSeconds (1);
onPoint = false;
}
}
That script is triggered from a script in my player file:
if(shipTrigCollision.gameObject.tag == "TrianglePickup"){
PointGet = true; // Sets the statement as true in our pointget script
audio.PlayOneShot(trianglePickupCollideSound);
Destroy(shipTrigCollision.gameObject); // Destroys the game object
}
That script is triggered from a FixedUpdate function in the player file, i have no idea what i am doing wrong. I would be grateful if someone could point at the errors :)
Answer by whydoidoit · May 24, 2012 at 04:12 PM
It looks to me like you aren't accessing the right property in the second script.
You should perhaps make the onPoint definition in the first section be this:
static public var onPoint : boolean = false;
Then in the second script in place of:
PointGet = true;
do
PointGet.onPoint = true;
Another point is that you usually can't use FixedUpdate as coroutine. Also fixedUpdate should only be used for Physic movement related stuff. Usually you use Update for most things.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071905im_/https://answers.unity.com/themes/thub/images/avi.jpg)