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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Function when actor collides

For a projectile, I need to get whenever my projectile hits any other object.

Fist I tried to use

 MeshComponent->OnComponentHit.AddDynamic(this, &AProjectile::OnHit);

Unfortunately this is extremely unreliably (It only works when my projectile hits certain parts of my NPCs to be exact)

Then I tried to use the ReceiveHit-function like this:

 void AProjectile::ReceiveHit(class UPrimitiveComponent * MyComp,
 class AActor * Other,
 class UPrimitiveComponent * OtherComp,
     bool bSelfMoved,
     FVector HitLocation,
     FVector HitNormal,
     FVector NormalImpulse,
     const FHitResult & Hit)
 {
     Super::ReceiveHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);
     GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Green, "ReceiveHit() Called");
 }

But it is never called.

What am I doing wrong? How do I do this properly?

I also posted a thread in the forum, in case you need more information: https://forums.unrealengine.com/showthread.php?54019-Get-Colliding-Actors

Product Version: Not Selected
Tags:
more ▼

asked Dec 12 '14 at 06:20 PM in C++ Programming

avatar image

HammelGammel
48 3 5 10

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

4 answers: sort voted first

Rather than binding an even to the component, I'd use overlap events. Look for

void ReceiveActorBeginOverlap(AActor* Other)

more ▼

answered Dec 13 '14 at 12:30 AM

avatar image

joeGraf STAFF
1.5k 35 12 69

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

I don't need to get when it overlaps though but when my projectile actually collides with another actor. I have collision enabled on my projectile but still need to have some functionality when it hits another actor if this makes more sense.

more ▼

answered Dec 13 '14 at 12:46 AM

avatar image

HammelGammel
48 3 5 10

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

Overlaps are collisions

more ▼

answered Dec 13 '14 at 12:48 AM

avatar image

joeGraf STAFF
1.5k 35 12 69

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

Of course they are collisions, but not the ones I need right now :)

I have a projectile with simulate physics and blocking-collision enabled. Now I need to get when it hits another actor. When it bounces off a wall for example. ReceiveActorBeginOverlap doesn't fire in this case.

more ▼

answered Dec 13 '14 at 01:08 AM

avatar image

HammelGammel
48 3 5 10

(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