How to make a trigger when a Collider hits a different collider

public GameObject planetone;

//Makes Planet One

void Planetone () {

int coinflip = Random.Range(1,3);

if (coinflip == 1){

int size = Random.Range (300, 500);

//int x = Random.Range(-8000,-10000);

int x = -8000;

int y = 0;

int z = 0;

planetone = GameObject.CreatePrimitive(PrimitiveType.Sphere);

planetone.name = "Planet One";

planetone.transform.localScale = new Vector3 (size, size, size);

planetone.transform.position += new Vector3(x,y,z);
			
SphereCollider ponesSphereCollider = planetone.GetComponent();

ponesSphereCollider.radius = 2;

ponesSphereCollider.isTrigger = true;
			
Rigidbody ponesRigidBody = planetone.AddComponent();

ponesRigidBody.constraints = RigidbodyConstraints.FreezePositionY;

ponesRigidBody.angularDrag = 0;

ponesRigidBody.useGravity = false;

	}

}

void OnTriggerEnter (Collider planetone) {
	Application.LoadLevel ("PlanetOne");
	}

I want to make it so that when another object with a collider or rigidbody passes through planet ones sphere collider it will switch to the PlanetOne Scene.

do i need to put anything in reference to the
void OnTriggerEnter (Collider planetone) {
Application.LoadLevel (1);
}
in my Start or Update ? and if so, how should i write it

did you check that the colider marked as trigger on your gameobject?

So as it stands now i can make the scene transfer but its instantaneous. I changed the code to look like this and now it wont scene transfer again.

public class SpawnSun : MonoBehaviour {

public GameObject sun;
public GameObject planetone;
public SphereCollider ponesSphereCollider;
public GameObject planettwo;
public GameObject planetthree;
public GameObject planetfour;
public GameObject planetfive;
public GameObject planetsix;
public GameObject planetseven;
public GameObject planeteight;
public GameObject planetnine;
private float BaseOrbitSpeed = 0.05f;

void Planetone () {

	int coinflip = Random.Range(1,3);

	if (coinflip == 1){

		int size = Random.Range (300, 500);

		//int x = Random.Range(-8000,-10000);
		int x = -8000;
		int y = 0;
		int z = 0;

		planetone = GameObject.CreatePrimitive(PrimitiveType.Sphere);
		planetone.name = "Planet One";
		planetone.transform.localScale = new Vector3 (size, size, size);
		planetone.transform.position += new Vector3(x,y,z);
		
		ponesSphereCollider = planetone.GetComponent<SphereCollider>();
		ponesSphereCollider.radius = 2;
		ponesSphereCollider.isTrigger = true;
		
		Rigidbody ponesRigidBody = planetone.AddComponent<Rigidbody>();
		ponesRigidBody.constraints = RigidbodyConstraints.FreezePositionY;
		ponesRigidBody.angularDrag = 0;
		ponesRigidBody.useGravity = false;
		//ponesRigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;

	}

}

void OnTriggerEnter (Collider ponesSphereCollider) {

	if (ponesSphereCollider.CompareTag("Player")) {

		Application.LoadLevel (1);
		Debug.Log ("Trigger has been hit.");
	}

	}

void Update() {
OnTriggerEnter (ponesSphereCollider);
}

Cool, thanks for the video. Looks like everything is setup correctly in the scene except for one thing. I didn’t see your custom script attached to the “PlanetOne” game object. In order for the trigger event to occur, you must attach your script containing the OnTriggerEnter() method to the game object that has the collider with the “Is Trigger” flag set to true.

In the picture, I’ve created a script called “YourScript” and have attached it to my “PlanetOne” game object. Once you select your game object, you can just drag and drop the script into the inspector window to attach it.

Inside of “YourScript” is the OnTriggerEnter() method. You do not need to call this yourself, so you can remove it from your update call. When the collision occurs, Unity will send a trigger event and your OnTriggerEnter() method will execute. Let me know if you run into any issues.