Help making a scenario (total beginner)

Hello, I am brand new to coding and Unity. I am trying to make a 2D scenario: there is a pie with a slice taken out (think pacman with an open mouth). The pie is rotating. the slice is floating above the pie. When you press space the slice will fall. You have to time it correctly so the slice will fall into the open slot in the pie. If it hits any other part of the pie, the game restarts. I tried setting this up, but the game restarts even if it does land in the slot correctly.

  • I put a polygon collider on the pie, made it a trigger.

-Then I put a polygon collider onto the slice.

-Then I made an Edge colider, into a V shape right above the open slot on the pie (NOT A TRIGGER)

-Added rigidBody 2d to both the pie and the slice

-Made them both have continuous collision Detection

What I was hoping would happen is that the slice would fall, and if it lands into the open slot, it collides with the edge collider, and just slides in (of course I would have to add code later to keep the slice in the slot or else it would fall out as the pie rotates.
-Instead, the game restarts, as if it still hit the polygon trigger! I am not sure why
Here is the code on the Pie:

public float degreesPerSec = 360f; 

void OnTriggerEnter2D(Collider2D other) {
	Application.LoadLevel (Application.loadedLevel);
}
void Start() { 
	Debug.Log("I am alive!");
} 

void FixedUpdate() { 
	float rotAmount = degreesPerSec * Time.deltaTime; 
	float curRot = transform.localRotation.eulerAngles.z; 
	transform.localRotation = Quaternion.Euler(new Vector3(0,0,curRot+rotAmount)); 
} 

Here is the code to make the slice fall:

void Start () {
	this.GetComponent<Rigidbody2D>().gravityScale = 0.0f;
}

// Update is called once per frame
void Update () {
	if (Input.GetKeyDown ("space"))
		this.GetComponent<Rigidbody2D>().gravityScale = 1.0f;
}

Here is a build of it, and pictures showing the components:

Thank you for any help!

Hi, no it doesn’t fall through the edge collider. In fact, if I make it flat and a little above the whole pie, the slide hits it and bounces of of it. So it is colliding, and it does collide when it is in the V shape as well, but, since the pie keeps rotating, it triggers the collision with it that restarts the level.

I am thinking if I set up code to have the pie STOP rotating once it touches the Edge collider, it WOULDN’T reset the level. I will see if I can code this (like I said total beginner).

This may be something to do with physics or collisions updating at the wrong time, so even though the slice should stop when it hits the edge colider, since the pie is rotating, the pie and slice still collide during an unseen frame update?