Hello, I need handle instantiating of GameObject by ,MarkInst" and ,CanMarkInst" bool, but when I hit mouse button 0 these bools go false but it still can instantiate when I am hitting mouse button 0β¦ Please help
using UnityEngine;
using System.Collections;
public class Smazat : MonoBehaviour {
public Camera cam;
public GameObject Marker;
public bool MarkInst = true;
public bool CanMarkInst = true;
public float x;
public float y;
public float z;
void Update() {
if (Input.GetMouseButton(0))
{
RaycastHit info;
if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out info))
{
x = info.point.x;
z = info.point.z;
y = info.point.y;
}
if(MarkInst == true && CanMarkInst == true)
{
Instantiate(Marker, new Vector3(x,y,z), Quaternion.Euler(1,1,1));
MarkInst = false;
CanMarkInst = false;
}
}
if (Input.GetMouseButtonUp (0)) {
x = 0;
z = 0;
y = 0;
}
}
}