- Home /
Checking to see where Roulette ball landed in the wheel
Hello! I am fairly new to Unity and am making a 2d roulette game. I have a ball that goes around a spinning wheel for a max of 11 seconds. I am trying to determine where the ball is once the wheel stops spinning. I added colliders to each "number slot" and am using onCollisonEnter2d to detect collisions and coroutine to wait 11 seconds before collisions can be detected. I am dropping the ball right into the 27 slot to test out my code. The code I have attached to the edge collider is using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class collision27 : MonoBehaviour {
public Text textbox;
// Use this for initialization
void Start()
{
StartCoroutine(Example());
}
IEnumerator Example()
{
textbox.text = "ball is rolling ";
yield return new WaitForSeconds(11);
}
void OnCollisionEnter2D(Collision2D col)
{
textbox.text = "Landed on 27";
}
}
When I run the game the textbox is saying "landed on 27" right away instead of waiting the 11 eleven seconds. Any Idea on how to delay the colliders detection for 11 seconds?
Your answer
Follow this Question
Related Questions
Lay a Sphere on a Point 3 Answers
Handling collision with fast Lerp 1 Answer
Object passes through collider even when isTrigger is turned off. 2 Answers
Continuous collision detection - unnatural behaviour 0 Answers
Is it safe to animate collision boxes? 3 Answers