- Home /
How to get Vector3.down in world space?
Hi, how can i get Vector.down in World Space?
I have tried with -transform.up but it's still local.
Here's my current code:
Vector3 fwd = transform.TransformDirection(Vector3.down);
RaycastHit hit;
if(Physics.Raycast(transform.position, fwd, out hit, 10000, 1)) {
if(hit.transform.name == "Landscape") {
print(Vector3.Distance(transform.position, hit.point));
}
}
The problem is, that it's using local space. How can I send a raycast directly down in World Space?
Thanks in advance.
Andreas.
Answer by Kiloblargh · Mar 01, 2014 at 11:04 AM
Vector3 (0,-1,0)
But if my gameObject is up-side-down it would not be Down but Up. How can that be fixed?
Physics.Raycast already uses world space. Vector3 (0,-1,0)
is down in world space. The entire problem is one you created for yourself by using "transform.TransformDirection," which did exactly what it is supposed to do and converted your local down vector into a world space direction.
Nice photo @$$anonymous$$iloblargh :D
-Vector3.up == down in worldspace also.
I'm not sure I understand why that picture is necessary, but I appreciate your help.
This just made my day :D I feel like a total idiot for not realizing that right away, but thanks for the laughs @$$anonymous$$iloblargh!