Код: Выделить всё
public void InputHandler()
{
if (pickUpText.enabled)
{
// Handle picking up the box
if (Input.GetKeyDown(pickUpKey))
{
overview.transform.position = cameraSpawnPosition;
Destroy(box1);
playerFirstPerson.enabled = false;
overview.enabled = true;
isOverviewCameraOn = true;
Debug.Log(isOverviewCameraOn);
}
}
if (isOverviewCameraOn)
{
Debug.Log("Overview camera is on, waiting for mouse click...");
PlaceBox();
}
}
private void PlaceBox()
{
Debug.Log("Place Box Is On Waiting For Left Click");
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Mouse Button Clicked!");
Vector3 mousePosition = Input.mousePosition;
Ray ray = overview.ScreenPointToRay(mousePosition);
Debug.DrawRay(ray.origin, ray.direction * 100f, Color.red, 1f);
LayerMask layerMask = LayerMask.GetMask("Ground");
RaycastHit hit;
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
Debug.Log("World Position: " + hit.point);
}
else
{
Debug.Log("No hit detected.");
}
spawnPlacedBox = new Vector3(hit.point.x, offsetY, hit.point.y);
Instantiate(box2, spawnPlacedBox, Quaternion.identity);
Debug.Log("Box Has Spawned!");
}
}
Также извините, если мой вопрос сбил с толку. Я новичок в программировании и переполнении стека.
Подробнее здесь: https://stackoverflow.com/questions/792 ... ouse-click