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"

How do I attach a projectile to another actor

I am attempting to create a 'sticky' projectile that when it collides with a Pawn, will stick to that pawn in the same location where it initially collided. This behavior is working to some extent, but the behavior I'm seeing is very odd. It seems like the Pawn the projectile attaches to is pushed around by the projectile after the attachment. That isn't the behavior I want, but I'm unclear as to how to achieve that behavior currently. Here is the relevant code which is called when colliding with a Pawn:

 AUTProj_Grenade::OnStick ()
 {
     ProjectileMovement->Deactivate();
 
     EAttachLocation::Type AttachLocationType = EAttachLocation::SnapToTarget;
     AttachRootComponentToActor(HitActor, NAME_None, AttachLocationType);
 }

I am not quite sure what needs to be done here to prevent my projectile from interfering with the Pawn movement while successfully attaching it to the Pawn.

Product Version: Not Selected
Tags:
more ▼

asked Jul 28 '14 at 05:01 AM in C++ Programming

avatar image

Wail
57 7 7 14

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

2 answers: sort voted first

You need to make the target and the projectile ignore each other during collision detection, something like

 RootComponent->MoveIgnoreActors.Add(HitActor);
 HitActor->GetRootComponent()->MoveIgnoreActors.Add(this);
more ▼

answered Jul 28 '14 at 07:53 AM

avatar image

Ogromord
41 4 5 7

avatar image Wail Jul 28 '14 at 03:41 PM

Hey, thanks for getting back to me on this. That was the correct solution although the syntax was a little off. For reference for those who might be curious what the exact solution was I am posting my code below.

 void AUTProj_Grenade::OnStick_Implementation(AActor*
 HitActor, const FVector& HitLocation) 
 {
 HitActor->GetRootPrimitiveComponent()->MoveIgnoreActors.Add(this);
 GetRootPrimitiveComponent()->MoveIgnoreActors.Add(HitActor);
 EAttachLocation::Type AttachLocationType = EAttachLocation::SnapToTarget;
 AttachRootComponentToActor(HitActor, NAME_None, AttachLocationType);
 }



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

I am also trying to "toss a ball and when it hits a pawn, it sticks to them". Think more like throwing a ball at a pawn and them "catching it" by sticking to them. How did you get yours working?

more ▼

answered May 24 '17 at 01:12 AM

avatar image

Elleclouds
1 2 3

(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