I Currently Participating In A Game Jam And I Need Help Creating Sort Of A Pressure Pad Where If You Put A Crate On It Or If You Stand On It The Button Goes Down And A Door Opens Or Somthing And Once You Get Off Or Once The Crate Gets Off The Door Closes And The Button Goes Back Up, I’m Using 2D Btw
Heres The Code I Used For The Button When Its Not Pressed(I Made 2 GameObjects And Put Then Active And UnActive When Player Gets Off Or Crate Gets Off):
public GameObject buttonwhenPressed;
void Start()
{
}
public void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.tag == "Crate")
{
buttonwhenPressed.SetActive(true);
gameObject.SetActive(false);
}
if (collision.gameObject.tag == "Player")
{
buttonwhenPressed.SetActive(true);
gameObject.SetActive(false);
}
}
// Update is called once per frame
void Update()
{
}
Heres The Code For The Button When Pressed :
public GameObject whenbuttonnotPressed;
// Start is called before the first frame update
void Start()
{
}
public void OnCollisionExit2D(Collision2D collision)
{
whenbuttonnotPressed.SetActive(true);
gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
}
Please Help And Ask Q If Your Confused