Синтаксис:
Используется csharp
if (Physics.Raycast(ray, out hit, 5f) && hit.collider.tag == "Block")
{
if (Input.GetMouseButtonUp(0))
{
Vector3 pos = hit.collider.transform.position;
pos += hit.normal;
Instantiate(block, pos, Quaternion.identity);
}
else if (Input.GetMouseButtonUp(1))
{
DestroyObject(hit.collider.gameObject);
}
}
else if (Physics.Raycast(ray, out hit, 5f) && hit.collider.name == "Plane")
{
if (Input.GetMouseButtonUp(0))
{
Vector3 pos = hit.point;
pos.y = 0;
pos.x = Mathf.Round(pos.x);
pos.z = Mathf.Round(pos.z);
Instantiate(block, pos, Quaternion.identity);
}
}
}
{
if (Input.GetMouseButtonUp(0))
{
Vector3 pos = hit.collider.transform.position;
pos += hit.normal;
Instantiate(block, pos, Quaternion.identity);
}
else if (Input.GetMouseButtonUp(1))
{
DestroyObject(hit.collider.gameObject);
}
}
else if (Physics.Raycast(ray, out hit, 5f) && hit.collider.name == "Plane")
{
if (Input.GetMouseButtonUp(0))
{
Vector3 pos = hit.point;
pos.y = 0;
pos.x = Mathf.Round(pos.x);
pos.z = Mathf.Round(pos.z);
Instantiate(block, pos, Quaternion.identity);
}
}
}