Question by
adjmpw · Sep 07, 2016 at 08:48 PM ·
unity 5triggercirclecollission
Check collission of rotating sprite is ground
I am using circle collider for a sprite and want to check if is touching the ground.I am using below code.Below code works perfectly for box collider and if z is fixed and when my sprite is not rotating.
The problem is when I use circle collider and when ball is rotating on the floor ,It calls OnTriggerExit2D multiple times.Can Some one tell me what is the solution.
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "floors") {
grounded = true;
Debug.Log ("entered");
}
}
void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.tag == "floors") {
grounded = true;
Debug.Log ("stayed");
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.gameObject.tag == "floors") {
grounded = false;
Debug.Log ("left");
}
}
Comment
Your answer
Follow this Question
Related Questions
Unity / Oculus - Touch object as trigger 0 Answers
Stop AudioSource on Trigger!!! 1 Answer
Tweening 50 circles 0 Answers
How to delete one Gameobject in a Trigger? 0 Answers
OnTriggerEnter is not working ? 0 Answers