- Home /
Vector3.down reverse y?
Hi, lets say Ive got a cube at point (0, 10, 0) and a Raycast going down from that cube until it hits my terrain at point (0, 0, 0) the Raycast is going down using Vector3.down. Since the Raycast is upside down is point (0, 10, 0) where it starts point (0, 0, 0) for the hit.distance so point (0, 9, 0) on the map would be point (0, 1, 0) on the Raycast point (0, 8, 0) on the map would be point (0, 2, 0) on the raycast etcetera.
so whats your question?
"Vector3.down reverse y?"
opposite of Vector3.down is Vector3.up
"so point (0, 9, 0) on the map would be point (0, 1, 0) on the Raycast point (0, 8, 0) on the map would be point (0, 2, 0) on the raycast etcetera."
Not sure what you are asking, but this is not true. If your Raycast starts at (0,8,0) for example, your hit.point will still be (0,0,0). As long as the 'y' value of the Raycast is above the terrain, you will get (0,0,0) for a Raycast at (0,?,0).
hit.distance gives you the distance from the beginning of the raycast to the point where the ray hits the other object. If you want the point where that hit occurs, you need to check hit.point. Check the docs here.
If your map is placed in (0,1,0) and the raycast is sent from point (0,10,0) then hit.distance equals 9. If the map is placed in (0,2,0) then hit.distance would equal 8 and so on.
Robertbu you answered my question I wanted to know if because the Raycast was going down would the y value at hit point be different to the map like if the x,y,z was turned upside down.
Answer by Reeceg · Feb 03, 2015 at 11:55 AM
Not sure what you are asking, but this is not true. If your Raycast starts at (0,8,0) for example, your hit.point will still be (0,0,0). As long as the 'y' value of the Raycast is above the terrain, you will get (0,0,0) for a Raycast at (0,?,0).
-robertbu