private void PerformRaycast() { HitObject = null; RaycastHit2D hit = default; int hitCount = Physics2D.RaycastNonAlloc(transform.position, Direction, Utility.HitBuffer, maxDistance.Value, ~ignoreLayer); for (int i = 0; i < hitCount; i++) { if (Utility.HitBuffer[i].collider.gameObject.TryGetEntity(out Entity entity)) { if (entity != Ability.Owner) { HitObject = entity; } else { continue; } } hit = Utility.HitBuffer[i]; break; } if (hit != default) { rendererHandler.UpdatePosition(hit.point); Debug.DrawLine(transform.position, hit.point, DebugColor); } else { rendererHandler.UpdatePosition(transform.position + (Vector3)Direction * maxDistance.Value); Debug.DrawLine(transform.position, transform.position + (Vector3)Direction * maxDistance.Value, DebugColor); } }
protected virtual void Animate() { float percentage = Mathf.Clamp01(TimeSinceFire / animationTime.Value); float animatedTime = animationTimeCurve.Evaluate(percentage); Vector2 interpolatedPosition = Vector2.Lerp(transform.position, AnimationTargetPoint, animatedTime); rendererHandler.UpdatePosition(interpolatedPosition); if (TimeSinceFire >= animationTime.Value) { Destroy(); } }