Hi everybody i have a problem, i am doing a 2d game where with mouse we must tap objects, i tried to use raycasts but does not Work here’s the code:
void Start()
{
Ray ray=Camera.main.ScreenPointToRay(Input.moisePosition);
}
void ClickFunction()
{
If(Physics.Raycast(transform.position,-Vector3 up,out Ray,100))
{
Destroy(GameObject.FindObjectWithTag("zombie");
}
}
When raycast collides should destroy the gameobject but does not Work.
What is wrong ?
Thanks in advance!