using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawLinesWithMouse : MonoBehaviour
{
public GameObject objectToDraw;
private List<Vector3> pointsList;
// Use this for initialization
void Start()
{
pointsList = new List<Vector3>();
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
RaycastHit hit;
Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 1000))
{
Vector3 hitpoint = hit.point;
pointsList.Add(hitpoint);
GameObject go = Instantiate(objectToDraw);
go.transform.position = hitpoint;
print(hitpoint);
}
}
}
}
If i move the mouse slow very slow it will Instantiate the cubes each one close to the other but once i move the mouse faster and faster there will be more spaces/distances between the cubes.
How can i make that there will be no spaces/distances between the Instantiated cubes even if i move the mouse very fast ?