How to make object orbit.

I am trying to figure out how to script in c# how to take an object from one location, use a player to collide into the object then have the object rotate around the player. This is not done in space so I need to figure how to remove gravity on the object.

Wanting the object to also move along all axis point in a circular motion. Any help or point me in the right direction would be very helpful!


Something like this would work:

-on your object use the following script:
GameObject player;

Bool orbiting;
Transform pos;
Float changeTimer;
Void Start(){
player = GameObject.Find("First Person Controller");
pos.position = new Vector3(2,0,0)

Void Update(){

If (orbiting){
changeTimer += Time.deltaTime;
If (changeTimer > 1) {
changeTimer = 0;
angle = Random.Range(0,340)
Vector3 r = new Vector3(Random.Range(0,360),Random.Range(0,360),Random.Range(0,360));
pos.RotateAround(player.transform.position, r, angle);
transform.localPosition = Vector3.Lerp(transform.position,pos.position,.1f);



Void OnCollisionEnter(Collision collision) {
if(collision.gameObject.tag == "Player"){
orbiting = true;
gameObject.transform.parent = player;