Q
Q
qsecretp2018-12-03 15:55:13
2D
qsecretp, 2018-12-03 15:55:13

How to use the OnCollisionStay2D function on another object?

the question seems to be simple.
here is the script.
public void OnCollisionStay2D(Collision2D other)
{
if ( I = 1 )
{
if (other.transform.tag == "Ground") {
OnGround = true;
}
}
if(other.transform.tag == "Ground")
{
//OnGround = true;
body.drag = 10;
jump = true;
}
}
Function works on object on which the script hangs, and it is necessary for me that it was possible to work with another without multiplying scripts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2018-12-03
@qsecretp

To answer the question directly, no.
OnCollisionStay2D is called for the object on which the script containing it hangs. As well as other MonoBehaviour functions - Update, Awake and more.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question