Question by
racsoknight · Apr 17, 2018 at 11:20 AM ·
gameobjectgetcomponentbooleanchildrenchild object
ChildsParentObject Function
Hi, i clone a GameObject several times as childs of another GameObject, but i want to detect if they are true from another script takes a new value, im new on c#, i made something like this but i don't know if im doing well...
Public class ParentScript : MonoBehaviour
{
ChildScript a;
public Vector3 pt1;
public Vector3 pt2;
public Vector3 pt3;
public Vector3 pt4;
void Start()
{
a = GetComponentsInChildren<ChildScript>();
}
private void Update()
{
if(a.clicked)
{
if(Input.GetMouseButtonDown(0))
{
a.Coordenadas = pt1;
Debug.Log("La pasición 1 es " + pt1);
}
if (Input.GetMouseButtonDown(0))
{
a.Coordenadas = pt2;
Debug.Log("La pasición 2 es " + pt2);
}
if (Input.GetMouseButtonDown(0))
{
a.Coordenadas = pt3;
Debug.Log("La pasición 3 es " + pt3);
}
if (Input.GetMouseButtonDown(0))
{
a.Coordenadas = pt4;
Debug.Log("La pasición 4 es " + pt4);
}
a.clicked = true;
}
else
{
a.clicked = false;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How can I move a gameobjects box Collider with another asset? 0 Answers
Get component from parent of children hittet with raycast 1 Answer
Activate all child objects in a Parent object 2 Answers
Difficulty setting script on gameObject from another script. 0 Answers
What to use instead of GameObject.Find and GetComponent 2 Answers