Turning off and On emitters?

Hey,

So I have the high level goal of adding a boost mechanic to the toon tank game. When boosting the tank will move faster.

I have created and attached two UsceneComponets where I want to attach a emitter to spawn a vfx to only be active when boosting. However looking through the documentation I can’t find anything to turn off emitters only to spawn them? What would be the best way of actually controlling emitters. I noticed that some of the emitters can be set to die when their lifespan has expired. Would it be to constantly spawn in the vfx or is there a better way.

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Components", meta = (AllowPrivateAccess = "true"))
	USceneComponent* BoostEmitterPointLeft;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Components", meta = (AllowPrivateAccess = "true"))
	USceneComponent* BoostEmitterPointRight;

// In the cpp

	BoostEmitterPointLeft = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BoostEmitterPointLeft)"));
	BoostEmitterPointLeft->SetupAttachment(BaseMesh);

	BoostEmitterPointRight = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BoostEmitterPointRight)"));
	BoostEmitterPointRight->SetupAttachment(BaseMesh);

if(Boosting){

UGameplayStatics::SpawnEmitterAtLocation(this(Not sure if I should be using this or if I can use BoostEmitterPointRight , HitParticle,GetActorLocation());

}


I hope this makes sense what I am trying to accomplish thank you for any advice or feedback.

Using the particle component you should be able to use deactive

That should do the trick! Thanks I will let you know how it goes!~

I am using this code to active the emitters but nothing is appearing. I was using an if statement to check if they were nullptr and they always come out as nullptrs??? I have no idea why as I have set them in the BP version of the tank.

Anything look wrong here:

On Startup: ( in the .cpp)
	BoostEmitterPointLeft = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BoostEmitterPointLeft)"));
	BoostEmitterPointLeft->SetupAttachment(BaseMesh);

	BoostEmitterPointRight = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BoostEmitterPointRight)"));
	BoostEmitterPointRight->SetupAttachment(BaseMesh);

// in a function: 
	UGameplayStatics::SpawnEmitterAtLocation(this, TrackParticle, BoostEmitterPointRight->GetComponentLocation());
	UGameplayStatics::SpawnEmitterAtLocation(this, TrackParticle, BoostEmitterPointLeft->GetComponentLocation());


Header: 

	UPROPERTY(EditAnywhere,Category="Effects")
	UParticleSystem* TrackParticle;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Components", meta = (AllowPrivateAccess = "true"))
	USceneComponent* BoostEmitterPointLeft;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Components", meta = (AllowPrivateAccess = "true"))
	USceneComponent* BoostEmitterPointRight;

image

Change BoostEmitterPointLeft/Right to be ParticleSystemComponents with auto activate disabled and properly attached.

Then you should be able to use Activate/Deactivate as needed.

Thanks Dan, ( you can skip this question as I found a solution)

I am a bit lost on how to replace BoostEmitterPointLeft/Right to be ParticleSystemComponents with auto activate disabled and properly attached.

As far as I can tell the BoostEmitterPointLeft/Right are just point in space that point to a location.

I am looking at the documentation and have seem to found myself a bit lost :frowning:

Is there any way you could point out exactly where in my code I would replace the reference! Thank you in advance for taking the time to look at this I really appreciate it!

	ParticleTrailLeft = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("Particle Trail Left"));
	ParticleTrailLeft->SetupAttachment(BaseMesh);


	ParticleTrailRight = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("Particle Trail Right"));
	ParticleTrailRight->SetupAttachment(BaseMesh);

Header:


	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
	UParticleSystemComponent* ParticleTrailRight;
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
	UParticleSystemComponent* ParticleTrailLeft;

This is the solution I ended up on so far.

I was then able to move the locations and scale in BP.

Are you saying you’ve got a working solution?

Yes I still can’t turn off or on the emitter however it doesn’t really matter in this case.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms