1 using System.Collections;
2 using System.Collections.Generic;
11 [RequireComponent(typeof(LineRenderer))]
24 public RaycastHit hitPosition
26 get {
return _hitPosition; }
33 get {
return _objectHit; }
49 base.UpdateStraightRay();
58 List<Vector3> posl =
new List<Vector3>();
60 for (
int i = 0; i < this.proj_max_verts; i++)
62 float dist = (float)i / this.proj_resolution;
64 Vector3 dest = RayForward * dist;
67 posl.Add(transform.position + dest - Vector3.up * (dist * dist) / (proj_velocity * proj_velocity));
70 if(checkHit(posl))
break;
73 if (dist >= max_length)
break;
76 if (
new Vector2(dest.x, dest.z).magnitude > max_horizontal_distance) {
78 posl.Add(posl[posl.Count-1] + Vector3.down*100);
84 this.positions = posl.ToArray();
85 lr.useWorldSpace =
true;
86 lr.positionCount = posl.Count;
87 lr.SetPositions(this.positions);
91 private bool checkHit(List<Vector3> positions) {
92 if (positions.Count > 1 && AVR.Core.Utils.Phys.LineCast(positions[positions.Count - 2], positions[positions.Count - 1], out RaycastHit hit, hit_layerMask))
96 positions[positions.Count-1] = _hitPosition.point;
105 if (positions.Length > 1 && AVR.Core.Utils.Phys.LineCast(positions[positions.Length - 2], positions[positions.Length - 1], out RaycastHit hit, hit_layerMask))
109 positions[positions.Length - 1] = _hitPosition.point;
override void UpdateRay()
Updates the ray. Called from Monobehaviour.Update()
LayerMask hit_layerMask
Layermask used to selectively ignore colliders when casting a ray.
Base class for a ray. A ray is always cast in transform.forward direction of the object it is attatch...
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
override void UpdateStraightRay()
Updates a ray with mode==STRAIGHT
A more advanced type of AVR_Ray. The ray can be used to get the first object hit by it...
override void UpdateProjectileRay()
Updates a ray with mode==PROJECTILE
bool checkHit(Vector3[] positions)
bool checkHit(List< Vector3 > positions)