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"

Dynamically spawned actors only collide with the player and nothing else.

Hi,

I have a game where asteroids are spawned and target the player, currently they travel and delete themselves when they hit the player, however they should also delete themselves when they hit the platform the player is standing on.

This does not occur, I've made sure both the player and platform have Collision enable both have collision meshes etc. and have the same collision options set (see screenshots).

I use the following when setting up my asteroids.

 OnActorHit.AddDynamic(this, &AAsteroid::OnCollision);
 
 void AAsteroid::OnCollision(AActor *SelfActor, AActor *OtherActor, FVector NormalImpulse, const FHitResult& Hit)
 {
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Deleting Asteroid!"));
     Destroy();
 }

Any help would be greatly appreciated.

Product Version: UE 4.10
Tags:
more ▼

asked Jan 07 '16 at 04:20 PM in C++ Programming

avatar image

TitusONeill
1 2 3

avatar image Matthew J Jan 07 '16 at 10:00 PM

Hello TitusONeill,

Do either of these objects have "Use Simple Collision as Complex" set for their Collision Complexity in the static mesh editor? I've seen problems previously with collision on meshes set to that being spawned at runtime.

If not, just to test, I'd suggest adding a box collision each of them to see if those collision bounds might collide instead of the meshes. This is mainly to rule out the logic being the problem.

avatar image TitusONeill Jan 08 '16 at 09:38 AM

Hey Matt thanks for replying,

Both have their Collision Complexity set to "Default"

Giving them both a box collision didn't help either.

The Asteroid Objects are spawned by another actor that moves around,

 AAsteroid* CreatedAsteroid = GetWorld()->SpawnActor<AAsteroid>(GetActorLocation(), FRotator(0,0,0));
 
 They then have their Init Method Called
 
 CreatedAsteroid->Init(target->GetActorLocation());
 
 void AAsteroid::Init(FVector InitTarget)
 {
     OnActorHit.AddDynamic(this, &AAsteroid::OnCollision);
     Target = InitTarget;
     DirectionVector = (GetActorLocation() - Target);
     DirectionVector.GetSafeNormal();
     FRotator Rotation = FRotationMatrix::MakeFromX(DirectionVector).Rotator();
     SetActorRotation(Rotation);
 }
 
 Many thanks again for your time.
 
avatar image Matthew J Jan 11 '16 at 03:06 PM

Would it be possible to get a copy of your project? As this is something I haven't seen before, this would most likely take quite a bit of back and forth with shot-in-the-dark answers. If so, you can send me a link in a private message on our forums. Heres my profile. A couple things to look at though would be the details panel after these asteroids are spawned to make sure that all of the collision is set up correctly at runtime as well. You might also want to try changing the OnActorHit to OnActorBeginOverlap just to see if it may trigger.

avatar image Matthew J Jan 15 '16 at 07:00 PM

Thank you for sending me the project, Titus. I'll let you know if I find out why these asteroids won't collide with the floor. It may be related to the delegate as they will push the floor mesh if the floor mesh is simulating physics.

avatar image Matthew J Jan 21 '16 at 02:39 PM

Hello Titus,

I'm still looking into this issue, I just wanted to leave a comment here to let you know that I haven't forgotten about your question.

avatar image TitusONeill Jan 21 '16 at 08:03 PM

No worries very thankful for your help.

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

2 answers: sort voted first

If you are using SetActorLocation without doing a sweep, you won't get a blocking hit event, because it's a teleport that is unblocked. Overlap events however would still be generated.

more ▼

answered Feb 04 '16 at 06:36 PM

avatar image

zeroexception STAFF
1k 18 16 39

avatar image zeroexception STAFF Mar 09 '16 at 11:57 PM

I got a chance to look at the sample project, and there are 2 issues with it:

1) The SetActorLocation node has bSweep = false, meaning it will ignore collisions as it moves. 2) The MockAsteroid BP is trying to get a hit event for the StaticMesh attached to the root component. We only get a blocking hit for the root component if it is being moved by SetActorLocation.

If I change the SetActorLocation to use bSweep and change the StaticMesh to be the root of the asteroid things work fine.

avatar image TitusONeill Mar 10 '16 at 09:30 AM

Many thanks for your time Will put in those changes

Thanks Again

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

Thank you for your patience, TitusONeill.

While I couldn't find out exactly why the hit events aren't working, I have found a possible workaround for you. It would involve using Overlap events instead of Hit events. If you set the asteroid to overlap the collision channel (Object Type) that the floor is set to, it should be able to fire overlap events. If you only want it to happen with the floor and not other WorldStatic objects, you could either set up a custom collision channel for the floor to use or cast to it using the actor reference.

I've reported the issue for the hit events but this should be a viable workaround for not. For reference, the bug number is UE-26257.

Please let me know if you run into any other issues. Have a nice day!

more ▼

answered Feb 01 '16 at 03:03 PM

(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