- Home /
RAYCAST KNOWLEDGE HELP!!!
i want to know if my raycast doesnt colide and if it is, so if it is i want my raycast to be the same as a distance var, if not i want that distance to the same as let say 10.... i already did the part if it is colliding but i cant know if it doesnt collide...
Comment
Best Answer
Answer by DaveA · Oct 23, 2012 at 06:05 PM
If I understand that you want to know when a ray of a certain distance does NOT collide with something? Then it just doesn't.
var hit : RaycastHit;
if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
var distanceToGround = hit.distance;
}
else
print ("it did not hit anything");
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Raycast length must be equal to the target distance 2 Answers
Collision position - Improving on the 'grounded' mechanic 2 Answers
hide child object script - help 1 Answer
Can I fake physics? 1 Answer