What do Vector3s do in a ray?

using UnityEngine;
using System.Collections;

public class Raycast : MonoBehaviour 
{

	
	void Update () 
	{ Ray ray = camera.ScreenPointToRay(new Vector3 [VECTOR3 VALUES!](0, 20, -20));
		Debug.DrawRay(ray.origin, ray.direction * 10, Color.magenta);
		Debug.Log ("crabs");
	}
}

I have my ray here, and it seems like its working just fine. It works when I run it, but I’m confused as to what the vector3 values in it do. I tried changing them but it doesn’t make my debug ray look any different. So what do they do? Are they actually making the real ray different and don’t effect the debug ray?

It’s the xy position on the screen… in pixels.

i.e. here you can get from mouse position

http://forum.unity3d.com/threads/screenpointtoray-mouseposition.38646/

different rays can be any line in the game space, intercepting GO’s

A guess, from the ScreenpointToRay docs: (position.z is ignored).

If you aren’t sure why that should be, read up more on what spToRay does.

Then, read up on rays. Origin and Direction mean what they say. Changing Origin (but not direction) by a few hundred pixels will look about the same. Then check how direction vectors work. (0,0,1) and (0,0,999) are the same direction.

[edit, response to comments]
There are several different things, which interact, but are still different:

o Vector3s are like floats. You can use a float to store seconds, or meters, or health … . Just because two things use a float, doesn’t mean they have anything in common. Vector3s are the same way. You have to keep straight which V3, and what does it mean.

o Rays are arrows in the game world. Origin is a spot in the world, in meters, the same numbers as when you place an object. Direction is unitless, like all direction Vectors. Both happen to be stored in Vector3s.

o MousePosition happens to use a Vector3 to store x and y pixels. It’s just boring old pixels. If your mouse is in the center of the screen, you can move the camera around all day, and mouseposition will always be (700,400)

o ScreenPointToRay looks at the camera in the game world. If you click on your camera, look at the small white square. SPtR takes the mousePosition, and does a ton of math, divides by pixels, … to figure where the mouse would be on that square. If your mouse is bottom center of the screen, it works out all the math to compute bottom center of that square. At that point pixels have been “cancelled out” and we’re done with them. SPtR figures the spot in world coords, which is the ray origin.

Then it draws a line from the camera, through that point. That’s the direction.

So mousePosition + camera position + camera facing determines ray origin, and direction. It’s always from the camera through somewhere on that small square (and goes out somewhere through that big rectangular cone.)