- Home /
Unexpected behaviour of OnTriggerStay2D
Hello Everyone, I have a script RotateAndColor.cs attached on a tile and tile has 2 child gameobjects with circle colliders and dynamic rigidbody2d.
I have two box colliders burn and blast with trigger checked.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateAndColor : MonoBehaviour
{
public SpriteRenderer pipe;
public bool yellow, red, blue;
private void OnTriggerStay2D(Collider2D collision)
{
Debug.Log("TriggerStay");
if (collision.CompareTag("burn"))
Debug.Log("burn");
if (collision.CompareTag("blast"))
Debug.Log("Blast");
}
}
So I am trying to print "burn" if tile is in burn trigger area and "blast" if tile is in blast trigger area. 1. So black area is burn trigger area and red is blast trigger area. You can clearly see circle collider 2d is in burn area but in output "burn" is printed only 38 times and not printed repeatedly in all frames but "blast" and "TriggerStay" is printed repeatedly I cannot figure out solution. Please Help. Thank You in advanced.
Your answer
Follow this Question
Related Questions
Why is my 2D Collision Delaying or Missing? 0 Answers
OnTriggerEnter/Stay/Exit2D() Not Working Consistantly 1 Answer
How do i stop rigidbody2D bounce 1 Answer
Stand-up dummy physics 1 Answer