protected virtual void FixedUpdate() { var newPosition = transform.position; var rayLength = (newPosition - oldPosition).magnitude; var rayDirection = (newPosition - oldPosition).normalized; var hit = Physics2D.Raycast(oldPosition, rayDirection, rayLength, RaycastMask); // Update old position to trail behind if (rayLength > MaxLength) { rayLength = MaxLength; oldPosition = newPosition - rayDirection * rayLength; } transform.localScale = MaxScale * D2dHelper.Divide(rayLength, MaxLength); if (hit.collider != null) { if (string.IsNullOrEmpty(IgnoreTag) == true || hit.collider.tag != IgnoreTag) { if (ExplosionPrefab != null) { Instantiate(ExplosionPrefab, hit.point, Quaternion.identity); } Destroy(gameObject); } } }