Announcement

Collapse
No announcement yet.

SetBeamTargetPoint is causing crashes in UE4

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SetBeamTargetPoint is causing crashes in UE4

    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:
    HTML 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!
    Last edited by OWO FESTER-SAMA; 10-14-2018, 06:55 AM.

    #2
    Here's the crash log if anyone is interested:
    HTML Code:
    UE4Editor_MyProject_8080!ABatteryPickup::WasCollected_Implementation() [d:\my stuff\unreal\unrealprojects\batterycollector(re)\source\batterycollector\batterypickup.cpp:38]
    And here's the line 38:
    HTML Code:
      ParticleEmitter->SetBeamTargetPoint(0, SocketLocation, 0);

    Comment


      #3
      UPDATE: I got it working now. My ParticleEmitter was just NULL.

      Comment

      Working...
      X