VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
virtual void AVR.Core.AVR_Ray.UpdateProjectileRay ( )
inlineprotectedvirtual

Updates a ray with mode==PROJECTILE

Reimplemented in AVR.Core.AVR_SolidRay.

Definition at line 148 of file AVR_Ray.cs.

148  {
149  List<Vector3> posl = new List<Vector3>();
150 
151  for (int i = 0; i < proj_max_verts; i++)
152  {
153  float dist = (float)i / proj_resolution;
154 
155  Vector3 dest = RayForward * dist;
156 
157  // Add new vertex to line
158  posl.Add(transform.position + dest - Vector3.up * (dist * dist) / (proj_velocity * proj_velocity));
159 
160  // Check if we're within distance limitations. NOTE: We are only restricting distance in the direction of transform.forward, not up or down.
161  if (dist >= max_length) break;
162 
163  if (new Vector2(dest.x, dest.z).magnitude > max_horizontal_distance) break;
164  }
165 
166  this.positions = posl.ToArray();
167  lr.useWorldSpace = true;
168  lr.positionCount = posl.Count;
169  lr.SetPositions(this.positions);
170  }
float proj_max_verts
Max. amount of vertices to use for projectile motion ray
Definition: AVR_Ray.cs:32
Vector3 RayForward
Definition: AVR_Ray.cs:53
float max_horizontal_distance
Will restrict the length of the ray along the xz-Plane to a given value.
Definition: AVR_Ray.cs:45
int proj_resolution
How many vertices per unit distance to use for projectile motion ray
Definition: AVR_Ray.cs:28
float proj_velocity
Starting velocity of the projectile motion
Definition: AVR_Ray.cs:37
float max_length
Maximum length of the ray
Definition: AVR_Ray.cs:43