- Home /
Question by
highpockets · Mar 06, 2013 at 07:22 AM ·
collidertriggeroptimizationontriggerstayprocessing
OnTriggerStay Question
Hi,
OnTriggerStay is being called once a frame even when the trigger is not in contact with a collider. Is this not needless processing power?
Comment
if you are doing debug.Log inside the OntriggerStay and in the Console you are checking the Log, check whether Collapse is not ticked. If no problem of that then plz share your script.
I ticked collapse and it is definitely being called every frame. $$anonymous$$y code is below.
void OnTriggerStay( Collider other )
{
Debug.Log(other.gameObject);
Debug.Log(gameObject.transform.position);
if( other.gameObject.layer == 9 && other.transform.position.y == gameObject.transform.position.y && other.gameObject.tag == "Drop Zone" )
{
other.gameObject.transform.position = new Vector2( gameObject.transform.position.x, gameObject.transform.position.y + 2.5f );
}
}
Debug.Log(other.gameObject); is na$$anonymous$$g the object (cubeA) that I want this game object (cubeB) to collide with when it stays on the trigger, but it is 3 units far away from the trigger while the function is being called every frame.