Is there a way to attach a particle system to the mouse so that it follows the cursor across the screen?
You could get the mouse postion, and then use that to determine where to move the particle system. Something like:
function Update () {
// Get the mouse position in pixels, and convert to camera view by dividing by the number of pixels the camera is displaying.
x = Input.mousePosition.x / mainCamera.pixelWidth;
y = Input.mousePosition.y / mainCamera.pixelHeight;
transform.position = Vector3(x, y, 0);
}
This one will be relative to the active camera.
function Update ()
{
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
// 10 meters in front of the camera:
transform.position = ray.GetPoint(10) ;
}
(Note i havent tried it out, so there might bea typo in the script)
Hi. Thanks for your help. I’m not sure why but with Ifrog’s script, Unity tells me “mainCamera” is an unknown identifier. I’m not sure what the fix for that is. Joachim’s script worked but “ScreenSpacePointToRay” is actually “ScreenPointToRay” - in case anyone else would like to try it out. It looks like that will do the trick but I need to play with the particles now to get them to look the way I want. Thanks again, guys.
You are getting error on mainCamera, because there is no variable defined called mainCamera.
The correct name for the camera tagged as the main camera is Camera.main.
I like Joachim’s script