laser sight

Hello, I need help with the beam particle component. I was following this Bp tutorial:- YouTube i was going to try and convert it to c++. I got it work in BP fine in my project, however, my c++ version doesn’t seem to be working. I believe my lane trace is fine, as the point light at the end of the beam is working, however, there is no beam showing. Again, it does work in my BP version, i must be doing something wrong with the particle component. Any help would be appreciated:

//laser sight
	UPROPERTY(VisibleDefaultsOnly, Category = "Laser")
	class UChildActorComponent* LaserSourceComp;

	UPROPERTY(VisibleDefaultsOnly, Category = "Laser")
	class UPointLightComponent* LaserImpactLight;

	UPROPERTY(EditAnywhere, Category = "Laser")
	class UParticleSystemComponent* LaserBeamPSC;

	UPROPERTY(EditDefaultsOnly, Category = "Laser")
	UParticleSystem* LaserBeamFX;

this is what is in my constructor

        LaserSourceComp = CreateDefaultSubobject<UChildActorComponent>(TEXT("LightSource"));
	LaserImpactLight = CreateDefaultSubobject<UPointLightComponent>(TEXT("LaserImpact"));
	LaserImpactLight->Intensity = 20.0f;
	LaserImpactLight->AttenuationRadius = 20.f;
	LaserImpactLight->LightColor = FColor(1.0, 0.0, 0.0);

	LaserBeamPSC = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("LaserBeam"));
	LaserBeamPSC->Template = LaserBeamFX;

this is my tick event

void ACharacter::Tick(float DeltaTime) 



	const FVector TraceStart = LaserSourceComp->GetComponentLocation();
	const FVector TraceEnd = TraceStart + (LaserSourceComp->GetForwardVector() * 5000);

	FCollisionQueryParams TraceParams(TEXT("Trace"), true, this);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;

	TraceParams.bTraceComplex = false;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(Hit, TraceStart, TraceEnd, ECC_Visibility, TraceParams);
	FVector_NetQuantize LaserTargetLocation;
	if (Hit.bBlockingHit)
		LaserTargetLocation = Hit.Location;
		LaserTargetLocation = TraceEnd;

	//this works
	//DrawDebugLine(GetWorld(), TraceStart, TraceEnd, FColor::Red, false, 1.0f);

	if (LaserBeamFX)
		if (LaserBeamPSC)
			//LaserBeamPSC->Template = LaserBeamFX;
			LaserBeamPSC->SetBeamSourcePoint(0, TraceStart, 0);
		        LaserBeamPSC->SetBeamTargetPoint(0, LaserTargetLocation, 0);

	if (LaserImpactLight)
		FVector lvNewLocation = LaserTargetLocation - LaserImpactLight->GetForwardVector();


Where you’ve used ‘LaserBeamPSC->Activate()’ - Try using ‘SetActive(true, true)’ instead, I’ve usually had more luck with that one!

Also, it’s possible that unless the beams locations are close to the actual emitter itself, they might be being culled by it’s bounds. To get around that (temporarily) you could just massively increase the bounds in the particle system itself and ensure that ‘Use Fixed Bounds’ is checked

You sir, are the man. That did it, thanks!!