After extensive searching online, I still haven't found a solution to my issue. If someone could offer some assistance, it would be greatly appreciated.
The script I'm working on is meant to place a prefab where the mouse has been clicked while another object, being followed by the camera, is falling down. The problem lies in the incorrect positioning of the cloned prefab. Initially, the coordinates at which it spawns are off, and as the object falls further, the prefabs continue to spawn in the same incorrect position if I don't move my mouse. To clarify, I want the prefabs to spawn at the X, Y coordinates in the game world where my mouse cursor is located.
var Xpos: float;
var Ypos: float;
var obj: GameObject;
function Update()
{
if (Input.GetMouseButtonDown(0))
{
// Debugging
Xpos = Input.mousePosition.x;
Ypos = Input.mousePosition.y;
Instantiate(obj, Vector3(Input.mousePosition.x, Input.mousePosition.y), Quaternion.identity);
}
}