Announcement

Collapse
No announcement yet.

OnBeginOverlap event missed when spawning actor in volume

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

    OnBeginOverlap event missed when spawning actor in volume

    I have an actor with a sphere component that I use for tracking Pawns within the sphere. All is well when a Pawn enters the sphere: OnBeginOverlap is triggered and OnEndOverlap is triggerred when it exists, but when a new pawn is spawned inside the sphere then neither is triggered. Only when the pawn leaves the sphere the OnBeginOverlap is triggered the next time it re-enters. Has anyone encountered it and does anyone know a way to make it trigger the OnBeginOverlap even when an actor is spawned inside it? Below the related code of the tracking actor.

    Creating the sphere in constructor:
    Code:
    	// Sphere for pawn tracking
    	RespawnSphere = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("RespawnSphere"));
    	RespawnSphere->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
    	RespawnSphere->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
    	RespawnSphere->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
    	RespawnSphere->ShapeColor = FColor::Green;
    	RespawnSphere->AttachTo(RootComponent);
    Initializing the sphere in actor's OnConstruction:
    Code:
    	RespawnSphere->SetSphereRadius(RespawnRadius);
    	RespawnSphere->OnComponentBeginOverlap.AddUniqueDynamic(this, &APortStructure::OnBeginOverlap_RespawnSphere);
    	RespawnSphere->OnComponentEndOverlap.AddUniqueDynamic(this, &APortStructure::OnEndOverlap_RespawnSphere);
    The functions that should be called:
    Code:
    void AMyActor::OnBeginOverlap_RespawnSphere(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool Something, const FHitResult& HitResult)
    {
    	// Do something
    }
    
    void AMyActor::OnEndOverlap_RespawnSphere(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
    {
    	// Do something
    }
    Journeyman's Minimap - Available on Marketplace - Forum topic - Video

    #2
    Bump, has anyone encountered this issue- or conversely used a similar setup but not encountered this?
    Journeyman's Minimap - Available on Marketplace - Forum topic - Video

    Comment


      #3
      I have the exact same problem, I want to know when I spawn an actor if yes or no it is inside the sphere, if it isn't it will dispawn and try again.

      Comment

      Working...
      X