- Home /
Accessing other objects
Hi, I'm really a beginner in Unity. I wonder how can I from script that belongs to one object access components from other object. Which function to use? I've found something like FindObjectWithTag() but I'm not sure if that's the right way
Comment
Answer by ScroodgeM · Aug 06, 2012 at 09:18 PM
if this object is one you have already, then:
declare a public variable in script
public Transform myTransform;
in editor, attach some transform to this script (script should be attached already to another some object). attach can be done by drag-n-drop
use this some transform in script simple
myTransform.position = ....;
Answer by fafase · Aug 06, 2012 at 09:25 PM
You have it all (or almost) answered here:
http://answers.unity3d.com/questions/246211/having-scripts-interact.html