Ahmed Taha
8
Q:

Add component object to gameobject unity

//to add a new ridgidbody
gameobject.AddComponent<Rigidbody>();
//to add a new meshCollider
gameobject.AddComponent<MeshCollider>();
//Original answer by MakerBenjammin6, cleanup by me.
7
//referencing a gameobject
public GameObject exampleObject;
//===============================================================>
private Rigidbody rb; //example of a component

public void Awake() {
	// adding a Rigidbody component to exampleObject
	rb = exampleObject.AddComponent<Rigidbody>();
  
	// referencing an existing Rigidbody component in exampleObject
	rb = exampleObject.GetComponent<Rigidbody>();
}
0
//This uses C# and unity
//to add a ridgidbody
gameobject.addComponet<ridgidbody>();
//to add a meshCollider
gameobject.addComponet<MeshCollider>();
//check out my profile
-1
void Reset()
{
  //Your code here
}
-1

New to Communities?

Join the community