How to make a GameObject dissapear when I'm close to them and click on them?
So basically I have an object that disappears when you click it, but the distance doesn't matter. I want to make the player go close to it, so it can click it. It's a pretty basic script that I'm using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectDissapearWhenClicked : MonoBehaviour {
private void OnMouseDown()
{
gameObject.active = false;
}
}
What am I supposed to do to also require the player to get close to the GameObject?
I appreciate the help.
Comment
Your answer
Follow this Question
Related Questions
raycast mouse detects any object 1 Answer
Change color of object on and off with click 1 Answer
change sound pitch on object 0 Answers
How to spawn an object on button click and make it follow the mouse until left click? 0 Answers
help me create a button to change or showing different object 0 Answers