So what i want to do is ray to drop objects so the ray will look down from the object and if it hits any object it places object being dropped on top. I’ve used rays with cameras but not sure how use it with gameobject with out a camera.
float disToObject = 10; //Change the distance your ray will fire accordingly;
public GameObject objectToSpawn;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward, out hit, disToObject))
{
Instantiate(objectToSpawn, hit.point, Quaternion.identity);
}
}
}
}