I need a raycast that points straight down at all times. I thought that using Vector3.down as my direction would do this. But this is not the result I’m getting. It seems to be drawing a ray of finite length to a specific place. What am I doing wrong?:
void Update () {
RaycastHit hitInfo;
if (Physics.Raycast(transform.position, Vector3.down, out hitInfo))
{
if (hitInfo.normal.y < 0.5)
{
canTransition = false;
}
else canTransition = true;
}
Debug.DrawLine (transform.position, Vector3.down, Color.cyan);
}
Debug .DrawLine is not the same as Debug .DrawRay
Currently you are drawing a line between your transform position an the coordinate of Vector3 .down aka Vector3(0, -1, 0).
Thanks, fffMalzbier. So what should I be using instead of Vector3.down to fix the non-visible raycast? It still seems to be not facing straight down.
Edit: so maybe it seems that my non-visible raycast is actually working correctly. Still unclear about whether or not I should be using Vector3.down.
twobob
March 20, 2015, 5:54pm
4
Debug .DrawLine (transform.[position - Vector3 .down](Unity - Scripting API: ), transform.position , Color .cyan );
he was saying you are going to a SPECIFIC place
as you said Vector3.Down is JUST 0,-1,0 which is where the line was drawing to…
transform.position - Vector3.Down is a meaningful, changing value over time, as you expected.
Ta.