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

Updates a ray with mode==PROJECTILE

Reimplemented from AVR.Core.AVR_Ray.

Definition at line 56 of file AVR_SolidRay.cs.

57  {
58  List<Vector3> posl = new List<Vector3>();
59 
60  for (int i = 0; i < this.proj_max_verts; i++)
61  {
62  float dist = (float)i / this.proj_resolution;
63 
64  Vector3 dest = RayForward * dist;
65 
66  // Add new vertex to line
67  posl.Add(transform.position + dest - Vector3.up * (dist * dist) / (proj_velocity * proj_velocity));
68 
69  // If we have 2 or more vertices check for collisions
70  if(checkHit(posl)) break;
71 
72  // Check if we're within distance limitations. NOTE: We are only restricting distance in the direction of RayForward, not up or down.
73  if (dist >= max_length) break;
74 
75  // Deal with max_horizontal_distance
76  if (new Vector2(dest.x, dest.z).magnitude > max_horizontal_distance) {
77  // We merely Linecast 100 units downward.
78  posl.Add(posl[posl.Count-1] + Vector3.down*100);
79  checkHit(posl);
80  break;
81  }
82  }
83 
84  this.positions = posl.ToArray();
85  lr.useWorldSpace = true;
86  lr.positionCount = posl.Count;
87  lr.SetPositions(this.positions);
88  }
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
bool checkHit(List< Vector3 > positions)
Definition: AVR_SolidRay.cs:91