- Home /
Question by
gopics · Sep 12, 2014 at 09:35 AM ·
terraindistancehitphysics.raycastupside-down
iam using raycast.hit function.am trying to move vehicle over the terrain ups and down??
good morning to all....actually am trying to move a car in ups and downs of the terrains using raycast function....simply i had a doubt in a physics.raycast function...i dont know how to set the parameters correctly.....i want to set the rays downwards...i want to calculate the terrain height....could anyone help me to correct the mistakes in physics.raycast function.....if am using this function my car gets up and doesnt gets down still it in flying state.....this is my code.....
if(physics.Raycast(transform.position,-vector3.down,out hit))
{
float distanceToGround=hit.distance;
float heightToAdd=transform.localscale.y;
target.Translate(0,transform.position.y-distanceToGround+heightToAdd);
}
(have more doubts in physics.raycast function parameters..)
Thanks in advance....
Comment