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"

Does IgnoreActorWhenMoving() actually work?


I have a Ship Pawn (Physically represented by a UStaticMeshComponent, Collision = BlockAll) that shoots projectiles (Actors with a SphereComponent as its root, Collision = BlockAll). Since the muzzle of the guns are actually inside the hit box of the ship, it crashes into its own Bullets everytime I shoot.

I read about IgnoreActorWhenMoving() and thought that this sounds like just what I needed. I wrote a BeginPlay() override in my Projectile Actor that looks as follows:

 void AProjectile::BeginPlay()
     if(AActor* Owner = GetOwner())
             // Ignore my owner
             PhysicalRepresentation->IgnoreActorWhenMoving(Owner, true);
         if(UPrimitiveComponent* Root = Owner->GetRootPrimitiveComponent())
             // Owner should ignore me
             Root->IgnoreActorWhenMoving(this, true);

But they still collide! I double checked that GetMoveIgnoreActors() returns the correct actors. It is not an option for me to set one or both of them to "OverlapAll" or "NoCollision" since I want them to collide with everything else.

I tried doing the same thing in Blueprints with exactly the same effect (which is none at all).

Edit: Here is my AProjectile Constructor (Actually much simpler than the UT projectile you posted...):

     PrimaryActorTick.bCanEverTick = false;
     PhysicalRepresentation = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Sphere"));
     RootComponent = PhysicalRepresentation;
     ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovement"));
     ProjectileMovement->bRotationFollowsVelocity = true;
     ProjectileMovement->MaxSpeed = 1000000.f;
     InitialLifeSpan = 3.f;
     this->bReplicates = true;
     this->bReplicateMovement = true;
     NetCullDistanceSquared = 10000000000.f;        ///< Visible up to 1000m away (seems to be sufficient)

Any suggestions are greatly appreciated.


Product Version: Not Selected
more ▼

asked Mar 06 '15 at 11:18 AM in C++ Programming

avatar image

18 5 7 10

avatar image Pierdek Mar 06 '15 at 11:53 AM

I had the same problem with my grenades projectiles. Even when IgnoreActorWhenMoving was set to pawn that holds grenade they still collide. It turned out that logic in the projectile works fine, the problem was caused by pawn movement component which sweeped that projectile and run depenetration logic.

Besides beginplay function may be to late to set ignoring actors. I would test setting ignore actor between

 CurrentGrenadeInTheHand = (UGameplayStatics::BeginSpawningActorFromClass(this, GrenadeInventory[CurrentSelectedGranadeType].GranadeClass, SpawnTM, true));
 CurrentGrenadeInTheHand ->MovementComp->UpdatedPrimitive->IgnoreActorWhenMoving(this, true);
 UGameplayStatics::FinishSpawningActor(CurrentGrenadeInTheHand, SpawnTM);

avatar image Oromis Mar 06 '15 at 12:33 PM

Thanks for your suggestion. I tried doing it between BeginSpawningActorFromClass and FinishSpawningActor, but nothing changed.

Regarding the first part of your answer, how did you solve that? I don't have a Character, so I don't have a CharacterMovementComponent...

avatar image Pierdek Mar 06 '15 at 12:53 PM

In my case the Character capsule collides with grenades. Can you post your AProjectile constructor, I would like to compare it with UT projectile components/colliders setup: https://github.com/EpicGames/UnrealTournament/blob/clean-master/UnrealTournament/Source/UnrealTournament/Private/UTProjectile.cpp

avatar image Oromis Mar 06 '15 at 01:59 PM

Sure, please have a look at my edit.

avatar image Pierdek Mar 06 '15 at 07:04 PM

Don't know how to help you, but I would reconsider using PhysicalRepresentation as static mesh component with blockall collision profile because this will always report a collision.

It seems that IgnoreActorWhenMoving is working only when you don't have physically based collider and the projectile is using Projectile movement component.

But if you insist on the static mesh collider what about disabling collision for certain amount of time and enable them when the projectile fly away from instigator?

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

1 answer: sort voted first

Hi David,

I know this is a very old question, but I couldn't find an easy answer to this on any other questions, so I thought I should answer for posterity's sake.

The API page for the IgnoreActorWhenMoving call says

"Components on the other Actor may also need to be told to do the same when they move."

I just coded up an example of an actor spawning a projectile, and I called IgnoreActorWhenMoving on the projectile's static mesh, but I also used MoveIgnoreActorAdd on the Actor responsible for spawning the projectile to make sure they don't collide with each other.

     ARadianceProjectile* proj = GetWorld()->SpawnActor<ARadianceProjectile>(Location, Rotation, SpawnInfo);

I have that code in the Controller for the actor responsible for spawning the projectile, and it seems to work great.

Hope this is helpful.

more ▼

answered Jul 02 '17 at 03:59 AM

avatar image

23 3 8

avatar image crossmr Sep 16 '18 at 08:43 AM

This is certainly a hard topic to find a lot of solid documentation about. Do you have a full example of all the code involved in this? It just seems to be little snippets here and there. Makes it hard to piece everything together. If I have a gun that shoots a projectile, this code will add the pawn holding it to the ignore actor list? Usually I set the gun not to block anything since i don't want it to act as a shield. But i have issues with forward momentum causing bullets to hit the player. Do I need to just include the ignore actor stuff from the original question?

(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