Attach Contoller At runtime

I want to have a choice of what GameObject I attach a Controller to. Any suggestions on how this would be done.

Searching the scripting referance for Attach, AddComponent, Parent, didn’t seem to turn up a function I could use to Dynamically add a Component at runtime

Mouse pick is the second issue, to get the object to attach to. But, that I think is more straight forward.

Thanks

AddComponent does, in fact, do exactly that.

Thanks, yes I found it a bit later. This did it.

if(!isAttached) {
Collider coliders = Physics.OverlapSphere(transform.position, 5);

		foreach(Collider c in coliders)
		{
			//print(c.ToString());	
			if( c.gameObject.tag.ToString() == "Attachable"){
				c.gameObject.AddComponent("MyController");
				isAttached = true;
			}
				
			
		}
		
	}