Updates the ray. Called from Monobehaviour.Update() An brief explanation on the math done here: Say alpha is the angle between RayForward and the y-axis. We want a minium alpha of 30°. Basic trigonometry tells us, that alpha >= 30° is equivalent with RayForward.y <= cos(30°). Consequently, RayForward.y will be clamped to exaclty cos(30°). What remains is setting the xz vector accordingly. Since the whole vector is normalized, the hypotenuse is 1. So pythagoras => 1^2 = |RayForward.xz|^2 + Rayforward.y^2 As a result, the length of RayForward.xz is equal to |RayForward.xz| = sqrt(1-RayForward.y^2) And since RayForward.y = cos(30°): |RayForward.xz| = sqrt(1-cos(30°)^2) = sin(30°) And this is what we do here. If the condition is violated, we set y=0, then multiply the normalized vector with sin(alpha) and finally set y to cos(alpha). Reimplemented from AVR.Core.AVR_SolidRay. Definition at line 71 of file AVR_MovementRay.cs. 82 reticule.transform.forward = new Vector3(Camera.main.transform.forward.x, 0.0f, Camera.main.transform.forward.z);
92 invalid_reticule.transform.forward = new Vector3(Camera.main.transform.forward.x, 0.0f, Camera.main.transform.forward.z);
Gradient m_InvalidColorGradient Definition: AVR_MovementRay.cs:47 GameObject reticule Reticule object displayed when a valid surface is hit Definition: AVR_MovementRay.cs:29 Gradient m_ValidColorGradient Definition: AVR_MovementRay.cs:38 GameObject invalid_reticule Reticule object displayed when an invalid surface is hit Definition: AVR_MovementRay.cs:33 RaycastHit hitPosition Raycasthit where the ray hit something. Contains the last hit the ray did if AVR_SolidRay.objectHit is false. null if the ray hasn't hit a single object in its lifetime. /summary> Definition: AVR_SolidRay.cs:25 bool objectHit True if the ray hit some object this frame. Use AVR_SolidRay.hitPosition to get the respective Raycas... Definition: AVR_SolidRay.cs:32 bool isValid Is this ray valid. The validity of a Raycasthit is determined on whether if AVR_MovementRay.filter satisfies the current hit. Definition: AVR_MovementRay.cs:60 |