I have a game where you get points by each input (mouse left click) you made to stay on a platform.
I want to prevent the player from spamming the input when he is already not colliding with the platform.
The platform do fall and regenerate as the player gets forward. Here’s how it is:
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.tag == "Player")
{
Invoke("Fall", 0.2f);
}
}
void Fall()
{
GetComponent<Rigidbody>().isKinematic = false;
Destroy(gameObject, 1f);
}
So my plan is to do the same exact thing (OnCollisionExit) but for the “Platform” tag. The issue is that I have no clue how to disable the input completely.
Can anyone help me with that?
Thank you a lot! 
I would set up a boolean and check if boolean is true to perform the action after a mouse press.
On Player
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShootOnClick : MonoBehaviour
{
public static bool onGround;
private void OnCollisionStay(Collision collision)
{
if (collision.gameObject.CompareTag("Platform"))
{
onGround = true;
}
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.CompareTag("Platform"))
{
onGround = false;
}
}
}
On Target
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static ShootOnClick;
public class ShotOnClick : MonoBehaviour
{
private void OnMouseDown()
{
if (ShootOnClick.onGround == true)
{
Destroy(this.gameObject);
}
}
}
In case you or another person reading this doesn’t notice, not that the target script says using static ShootOnClick. Without this line in the second script, or setting the bool onGround to public static in the first one, this would not have worked.
Now, for movement, you could put transform.Translate in an if statement to check if onGround is true.
Yes, you made it! Sorry for being stupid, this movement blocking was new to me.
I also blocked the player from increasing the score while mid air.
Thank you a lot for your time and help!