Hello everyone! I am following Battery Collector tutorial at the moment, and decided recreate one of the blueprint episode into C++. Here’s the code:
void ABatteryPickup::WasCollected_Implementation()
{
//Use the base pickup behavior (we just want to append our own code into an already existing parent's code)
Super::WasCollected_Implementation();
SocketLocation = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)->GetMesh()->GetSocketLocation(FName("spine_02"));
ParticleEmitter = UGameplayStatics::SpawnEmitterAttached(BatteryParticle,GetMesh(),FName("AttachPoint"),FVector(0,0,0),FRotator(0,0,0),EAttachLocation::SnapToTargetIncludingScale,true);
ParticleEmitter->SetBeamTargetPoint(0, SocketLocation, 0);
GetWorldTimerManager().SetTimer(BatteryDelayTimer,this,&ABatteryPickup::DelayBattery,DelayTime,false);
GetWorldTimerManager().SetTimer(UpdatingBeamTimer, this, &ABatteryPickup::UpdateBeam, DelayTime / 10, false);
}
void ABatteryPickup::UpdateBeam()
{
ParticleEmitter->SetBeamTargetPoint(0, SocketLocation, 0);
}
I expected everything to worked fine until the engine crashes on me whenever I called the “WasCollected_Implementation” function. My conclusion was that the SetBeamTargetPoint function was causing the problems due to the fact that they are the only thing when commented, don’t crash the engine. I want to know how do I avoid and what’s causing the problem? Thanks!