I am really frustrated, so much so that I am going to ask this last question and walk away from the computer and wait. I'm trying to use raycasts to get the current mouse position at a click. For now, I'm instantiating an object as a debugger. Here's my code:
var particle : GameObject;
function Update () {
if (Input.GetButtonDown ("Fire1")) {
// Construct a ray from the current mouse coordinates
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray)) {
// Create a particle if hit
Instantiate (particle, transform.position, transform.rotation);
}
}
}
Now, when I play the game, when I click, it instantiates the object right at the camera's position. What am I doing wrong? Any and all help appreciated.
Elliot Bonneville