Announcement

Collapse
No announcement yet.

Triggering engine breakpoint 50% of the time with a OnComponentHit Delegate?

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

    Triggering engine breakpoint 50% of the time with a OnComponentHit Delegate?

    EDIT: On further experimentation, it appears that it only happens when the object is generated in the level for the FIRST time, and I then hit 'PIE'. Hitting PIE subsequently causes no crash. It seems to only happen the first time the collision is set-up...

    Can't figure out why, but I keep triggering an engine breakpoint when I hit play with one of these classes in the level. I'm sure I've set everything up right, the called function is a UFUNCTION and has the BlueprintNativeEvent tag, so why am I hitting this breakpoint.

    Note, it happens when hitting either begin play or simulate...

    Powerup.H:
    Code:
    	/* Called When The Powerup Collision Overlaps With Something */
    	UFUNCTION(BlueprintNativeEvent)
    	void OnCollectOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
    PowerUp.CPP
    Code:
    ABZGame_PowerUp::ABZGame_PowerUp(const FObjectInitializer& ObjectInitializer)
    	: Super(ObjectInitializer)
    {
    	/* This actor needs to tick, otherwise it won't really do anything. */
    	PrimaryActorTick.bCanEverTick = true;
    	PrimaryActorTick.bStartWithTickEnabled = true;
    
    	/* Create the Crate Mesh */
    	CrateMesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("CrateMesh"));
    	GetCrateMesh()->SetSimulatePhysics(true);
    	GetCrateMesh()->SetAngularDamping(0.0f);
    	GetCrateMesh()->SetLinearDamping(0.01f);
    	GetCrateMesh()->SetPhysicsMaxAngularVelocity(1600.0f);
    	GetCrateMesh()->OnComponentHit.AddDynamic(this, &ABZGame_PowerUp::OnCollectOverlap);
    	RootComponent = CrateMesh;
    }
    Code:
    void ABZGame_PowerUp::OnCollectOverlap_Implementation(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
    {
    	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("Test")));
    
    	APawn* Collector = Cast<APawn>(OtherActor);
    	if (Collector)
    	{
    		//if (CanPawnCollect(Collector))
    		//{
    		//	CollectPowerUp(GetGameObjectFromOverlap(Collector));
    		//}
    		//else
    		//{
    		//	RejectPowerUp();
    		//}
    	}
    }
    Any ideas why this is? The fact that it's happening only a few times when I hit Play makes me wonder if it's an engine bug?
    Last edited by TheJamsh; 01-04-2015, 05:22 PM.

    #2
    Bump - Any ideas on this folks?

    It appears to happen ONLY when the object is first simulated, after that, the breakpoint goes away. Interestingly, it doesn't crash the editor, and play continues once the breakpoint has been hit.

    Comment

    Working...
    X