- Home /
Question by
dynamoo21 · Oct 24, 2016 at 06:13 AM ·
physicsraycastvector3reflection
Shoot Raycast to a specified Angle
I am making a behavior similar to Refraction In Unity. I m having some issues In raycasting the second ray. I have the Incidence i1 and refraction angle r2 but the raycast is not going at right angle.
Note: All this is In 3D mode.
public float AngleFromNormal(){
float incidenceAngle = 180-Vector3.Angle ( (hit.point-transform.position) , hit.normal );
Debug.DrawRay (transform.position, hit.point-transform.position, Color.yellow);
Debug.DrawRay(hit.point,hit.normal, Color.green);
Debug.DrawRay(hit.point,-hit.normal, Color.green);
return incidenceAngle;
}
public void DrawFirstRefraction(float refractionAngle){
Vector3 direction =new Vector3(refractionAngle,0,0);
Physics.Raycast (hit.point, direction , out hit_1);
if(hit_1.collider){
Debug.DrawRay(hit.point,hit_1.point,Color.blue);
}
}
problem-png.png
(16.5 kB)
Comment