game object .getcomponent script code example Example: unity gameobject.getcomponent rb = GetComponent<Rigidbody>();