Shotgun Trace

I’m making a 2D game and I want to make something like this with line traces:

41787-thing.jpg

And that’s what’s happening so far:

And that’s what I’ve written so far:

FCollisionQueryParams TraceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, this);
	TraceParams.bTraceComplex = true;
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = true;
	TraceParams.AddIgnoredActor(this);

	FVector Start = GetActorLocation();
	FHitResult Hit(ForceInit);

	float angle = 90;	// will be modifiable
	const float ang = angle / 2;
	uint8 divisions = 18;	// will be modifiable as well
	const float step = angle / divisions;
	float range = 500;	// that one too

	for (int8 i = ang*-1; i <= ang; i += step) {
		float h = sin(i) * range;
		float s = cos(i) * range;
		if (Controller->GetControlRotation() == FRotator(0, 180, 0))
			s *= -1;
		FVector End = FVector(Start.X+s, Start.Y, Start.Z+h);
		
		bool didHit = GetWorld()->LineTraceSingle(Hit, Start, End, ECC_Visibility, TraceParams);
		DrawDebugLine(this->GetWorld(), Start, Hit.TraceEnd, FColor::Red, true, 1000, 10);

		if (didHit) {
			ABasePawn* Bp = Cast<ABasePawn>(Hit.GetActor());
			if (Bp != NULL)
				Bp->TakeDamage(20);
			break;
		}
	}

I don’t want to have any aiming mechanics just yet so just ignore the gun.

Fixed it. The code should look like this:
FCollisionQueryParams TraceParams = FCollisionQueryParams(FName(TEXT(“RV_Trace”)), true, this);
TraceParams.bTraceComplex = true;
TraceParams.bTraceAsyncScene = true;
TraceParams.bReturnPhysicalMaterial = true;
TraceParams.AddIgnoredActor(this);

	FVector Start = GetActorLocation();
	FHitResult Hit(ForceInit);

	float range = 500;
	float angle = 90;
	uint16 divisions = 18;
	const float sAng = 90 - angle / 2;
	const float eAng = 90 + angle / 2;
	const float step = angle / divisions;

	for (int16 i = sAng; i <= eAng; i += step) {
		float x = sin(i*PI/180) * range;
		float y = cos(i*PI/180) * range;
		FVector End = FVector(Start.X + x, Start.Y, Start.Z + y);

		bool didHit = GetWorld()->LineTraceSingle(Hit, Start, End, ECC_Visibility, TraceParams);
		DrawDebugLine(this->GetWorld(), Start, Hit.TraceEnd, FColor::Red, true, 1000, 10);
	}