I have made scripts Test1 and Test2. Test1 script is looking for objects with script Test2, and when collides, variables are equating. But it works only 1 time. Thanks.
public class Test1 : MonoBehaviour
{
public string myName;
public Test2[] Cubes;
// Use this for initialization
void Start ()
{
Cubes = FindObjectsOfType(typeof(Test2)) as Test2[];
}
void OnCollisionEnter()
{
for(int i = 0;i<Cubes.Length;i++)
{
myName = Cubes*.name;*
-
}*
-
}*
-
// Update is called once per frame*
-
void Update ()*
-
{*
-
Debug.Log(myName);*
-
}*
}
public class Test2 : MonoBehaviour { -
public string name = “Name”;*
-
// Use this for initialization*
-
void Start ()*
-
{*
-
}*
-
// Update is called once per frame*
-
void Update ()*
-
{*
-
}*
}