Answers for "get component gameobject unity"

1

unity create gameobject with component

GameObject go = new GameObject("Test", typeof(MeshRenderer), typeof(MeshFilter), typeof(YourScript));
Posted by: Guest on July-16-2020
0

findobject getcomponent

GameObject.Find("Name of the object you want to access").GetComponent<Name of the Component (Transform,Script,RigidBody,etc..)();
     
     An Example (easy to understand):
     
     GameObject Player = GameObject.Find("Player");
     PlayerController PlayerControllerScript = Player.GetComponent<PlayerController>();
     PlayerControllerScript.run = true;
     
     Another Example:
     
     GameObject.Find("Player").GetComponent<PlayerController>().run = true;
Posted by: Guest on June-14-2020

Code answers related to "get component gameobject unity"

Browse Popular Code Answers by Language