Download

C++ UInterface and IsSimulatingPhysics on a Character

hello,
I have tried to impliment a simple interface that will hold a field called health


#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "Target_Interface.generated.h"

// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UTarget_Interface : public UInterface
{
    GENERATED_BODY()
};

/**
 * 
 */
class LOST_API ITarget_Interface
{
    GENERATED_BODY()

    // Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:

    float health;
};


I put it on here


class LOST_API AAI_Zombie_Character : public ACharacter, public ITarget_Interface


I Set Health to 50 in my contractor


AAI_Zombie_Character::AAI_Zombie_Character()
{
     // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;

    bUseControllerRotationPitch = false;
    bUseControllerRotationRoll = false;
    bUseControllerRotationYaw = false;


    GetCharacterMovement()->bOrientRotationToMovement = true;
    GetCharacterMovement()->RotationRate = FRotator(0.0f, 600.0f, 0.0f);
    GetCharacterMovement()->MaxWalkSpeed = 100.0f;

    health = 50.0f;
}

When i shoot the AI Character i tried to get the health and lower the value but each time i got that health equals to 0


void ALostProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
    // Only add impulse and destroy projectile if we hit a physics
    if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL) && OtherComp->IsSimulatingPhysics())
    {
        /*OtherComp->AddImpulseAtLocation(GetVelocity() * 100.0f, GetActorLocation());*/
        if (ITarget_Interface* TheInterface = Cast<ITarget_Interface>(OtherActor))
        {
            TheInterface->health--;
            UE_LOG(LogTemp, Warning, TEXT("enemy Health %d"),TheInterface->health);
        }
        Destroy();
    }
} 

Another thing is that i am trying to get the character while IsSimulatingPhysics set to true in the Blueprints but it says:
Invalid Simulate Options: Body (BP_AI_Zombie_Character_2.CharacterMesh0 SK_Mannequin) is set to simulate physics but Collision Enabled is incompatible
How can i fix this issue as well?
(i want to make the character move a bit when he gets hit by a bullet)