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.
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;
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
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!