Create Stake Gun Projectile

Hello, i’m trying to create a projectile that behaves like the Stake Gun form Painkiller. Right now i’m doing the following:

I’ve created a Projectile with a Box Component as the root, a Static Mesh for the stake mesh and a Projectile Movement Component. When the projectile hits a character he puts the it into ragdoll mode and then i attach the projectile to the impact location using:

this->AttachRootComponentTo(Character->GetMesh(), HitResult.BoneName, EAttachLocation::KeepWorldPosition);

This is working fine, but i noticed that after the Hit event the projectile stops and i wanted it to continue it’s path till it finds a wall or floor to stick, meanwhile the character mesh would be dragged. I’m having a hard time with this part. Can you help me out? Thank you :slight_smile:

Currently i tried 2 ways. One is the projectile overlaps the character and OnComponentBeginOverlap i set ragdoll mode and i try to attach the rootcomponent of the character and the mesh to the projectile, the rootcomponent works well and follows the projectile, the mesh follows the movement but doesn’t stick properly. The other way was the projectile hits the character and attaches the projectile to the character (code above) and then tries to resume the movement of the projectile. The attach works well, but i’ve been having problems making the projectile resume it’s movement. I tried faking the projectile movement by adding a constant force in the direction of the hit, it’s not that bad, but it’s not the same.

Yes this sounds like a physical issue, when you attach the actor, the weight will increase ALOT. I would say there is a big chance that the stake need more force (higher exit velocity), or you need to temporary scale the weight of the raggdoll down to make it easier to move.

But that is just a educated guess on my part.

But for what approach? The overlapping one? That seems to be the one that produced the best results, because the projectile never stops. Right now i’m doing this OnComponentBeginOverlap for my projectile:

CollisionComp->SetCollisionResponseToChannel(ECC_Pawn, ECollisionResponse::ECR_Ignore); // Ignore further collisions with pawns so BeginOverlap is not always triggering, could this be a problem?
Character->AttachRootComponentToActor(this, NAME_None, EAttachLocation::KeepWorldPosition, true);  // Attach the character's capsule component to the projectile
Character->GetMesh()->AttachTo(Mesh, NAME_None, EAttachLocation::KeepWorldPosition, true); // Attach the character's mesh to the projectile

Can you help me with this please? I just want to attach the character mesh to the projectile and let it continue the movement, but it’s being really hard to pull this off :S

Well, I would make the projectile attached to the ragdoll, then make the ragdoll move in a way that looks like the projectile is continuing its motion. Maybe by adding force at the hit location, setting the physics velocity, impulse, etc.

I already tried that, if it’s to add a little impulse it works fine, but if it’s to travel a bigger distance i tried adding a constant force on the direction of the hit and looks really fake. Another problem i have with that implementation is that when the enemy is in ragdoll with the stake attached, if i try to fire another stake, it won’t stick the same way, it will have a huge offset, i’m using this code:

this->AttachRootComponentTo(Character->GetMesh(), Hit.BoneName, EAttachLocation::KeepWorldPosition);

CollisionComp->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Ignore);

Can you explain to me what each EAttachLocation does exactly? I’ve used KeepWorldPosition because it was the only one that worked for the first hit. Another question, is there a way to have multiple update components for the projectile movement? because i want to have one collision box to collide with the pawn and another one at the tip of the projectile to detect walls, so that it’s possible to attach to a character and to a wall at the same time if it’s close enough to it. Thank you :slight_smile:

Snap will give it the same location and orientation as the bone/socket you tell it to attach to. By offset do you mean that you are hitting the capsule component instead of the mesh?

The capsule component ignores projectiles, so it’s just the enemy mesh and the projectile colliding. When i put the enemy in ragdoll he gets separated from the capsule component.

Hello, xlar8or did you manage to solve this problem? I’m also trying to implement this kind of gun. Can you share with me your experience in that matter ?