- Home /
Non-hard-coded object reference?
I have a script that checks if a condition is true, then performs an action, which is move a cube (performed in a script attached to the object moved, the detecting is attached to the object that is the conditional). If I attach the movement script to another object, though, it moves both objects. What can I do (without hard-coding, as there will be hundreds of these events and we don't want hundreds of scripts with only different variables) to pick which gameObject to use like I can with variables in the object components?
Answer by IHazABone · Oct 08, 2013 at 01:41 AM
Figured it out - declaration should be var varName : GameObject;
Answer by DaveA · Oct 07, 2013 at 06:44 AM
use 'name' or gameObject.name etc.
No no, what I mean is this: when you have a variable in a script, and apply it to an object, you can change the variable in the component window of the object. How can I do that but with objects in the game rather than variables?
Your answer
Follow this Question
Related Questions
static var for one object. 2 Answers
Get game component type? 1 Answer
Get Vector3 position of player? 0 Answers
Setting Scroll View Width GUILayout 1 Answer