- Home /
Question by
Pedre · Jan 21, 2014 at 08:16 PM ·
playergetcomponent
Can't modify variable from another gameobject script
Well, i just want to change to true a boolen on my player script from another script this is the way i tryed out:
(MAIN CLASS) player_behaviour pb = player[selected_char].gameObject.GetComponent(); pb.selected = true;
(PLAYER CLASS) public bool selected; void Start(){ selected = false; }
Of couse i apply this call much after of player script start function, thanks for you helping.
Comment
You should format your code and provide the complete error to increase your chances of having this question approved. There's a link to a tutorial video on the right side of the screen, if you do not know how to do these things. -->