x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Cannot get into NotifyHit function

I am trying to get a function to call in my pawn class whenever my pawn bumps into something or hits it. (It's going to damage the ships shields based on how hard I hit an object.)

I am using a pawn with the starter content UFO guy for now as I get the game working.

I am trying to simply override the NotifyHit function Here's what I've got:

In the Pawn's header:

     UFUNCTION()
         virtual void NotifyHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;

In the Cpp:

 void ATestPawn::NotifyHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
 {
     GEngine->AddOnScreenDebugMessage(1, 15.0f, FColor::Red, "I am being notified of a hit.");
 }

I do not get into this function at all.

Product Version: UE 4.8
Tags:
more ▼

asked Jul 17 '15 at 12:58 AM in C++ Programming

avatar image

ekcell
21 3 4 6

avatar image ekcell Jul 17 '15 at 01:05 AM

I forgot to mention but I DO have the following line in the pawn's constructor: SetActorEnableCollision(true);

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

On the Root Mesh Component I had to enable the following settings.

 PawnMeshComponent->SetNotifyRigidBodyCollision(true);

I should point out that This C++ variable corresponds to a bool in the editor named: Simulation Generates Hit Events. One of these names should probably be updated to more appropriately reflect the other.

Thank you.

more ▼

answered Jul 17 '15 at 02:04 AM

avatar image

ekcell
21 3 4 6

avatar image Ch3shireCat Feb 02 '17 at 09:46 PM

Thanks, it actually solved my problems.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question