I'm trying to make little building game, where I want to take the x/z position of the mouse along with a certain y position, then round those to integers. Then I instantiate an object at that final position. It keeps spawning the block at a location hundreds off, for example when I click at 0,0,0 it spawns a block at 580.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Building : MonoBehaviour
{
public GameObject Block;
void Update(){
int mousePosX = Mathf.RoundToInt(Input.mousePosition.x);
int mousePosZ = Mathf.RoundToInt(Input.mousePosition.z);
if(Input.GetButtonDown("Fire1")){
Instantiate(Block, new Vector3(mousePosX, 0.15f, mousePosZ), Quaternion.identity);
}
}
}