How do i prevent a Projectile Movement Component to stop when it hits something?

Hello, i have a projectile with a Projectile Movement Component, and when it hits a character i want it to continue its movement, but it currently stops, how do i prevent that? I tried setting the character to overlap the projectile and added a OnComponentBeginOverlap but he’s not detecting the character (i put the capsule collider to ignore projectiles and the mesh to overlap it, on the projectile i set it to overlap pawns).

Right now with the overlap approach he’s not triggering the callback for overlaps. But i want the projectile to keep going and only stop when he hits a wall or the floor.

I can’t be too sure but try it so when the projectile overlaps with something, it’s projectile velocity drops to 0 ?

Looking for the answer to this as well. I have a spherical shield and my player fires from within the shield. When a hit is detected (as soon as the projectile spawns) the projectile stops. My understanding based on another related question is that as soon as a hit is detected the ProjectileMovement is detached. I tried using an OnProjectileStop delegate but am having no luck with this. Seems like there should be an easy solution. Hop someone knows.

In your case you can set the projectile to ignore the shield object type in the collision options.

Having exactly same problem. I don’t know how to make my projectile keep moving after it hits anything. When setting velocity for the bullet right after the hit event for the projectile movement component, it seems to have that velocity, but apparently nothing happens.

I did this a while back and i think it works:

ProjectileMovement->OnProjectileStop.AddDynamic(this, &AProjectile::OnStop);

void AProjectile::OnStop(const FHitResult& Hit)
{
    ProjectileMovement->SetUpdatedComponent(CollisionComp);
    ProjectileMovement->Velocity = FVector(1000.0f, 0.0f, 0.0f);
    ProjectileMovement->UpdateComponentVelocity();
}
1 Like

Thanks alot for pointing out the solution for me. After reading various posts about the same problem I started examining UProjectileMovementComponent class and I realized there’s a function HandleImpact that gets executed when hit event is registered. Unless the bullet is set to bounce, StopSimulating function will get executed, which does the following:

void UProjectileMovementComponent::StopSimulating(const FHitResult& HitResult)
{
	SetUpdatedComponent(NULL);
	Velocity = FVector::ZeroVector;
	OnProjectileStop.Broadcast(HitResult);
}

I had idea to create subcomponent based on projectilecomponent, override this function and do nothing in that function. But your solution is really great aswell.

Thank you,

With regards.

Hello!

I lurked around in the documentation of UProjectileMovementComponent and I think I found more effective way to make the bullet unstoppable.


SOLUTION

  1. Create UProjectileMovementComponent inheriting movement component class

  2. Add lines to your created component class to override next functions:

    EHandleBlockingHitResult HandleBlockingHit(const FHitResult& Hit, float TimeTick, const FVector& MoveDelta, float& SubTickTimeRemaining) override;
    void HandleImpact(const FHitResult& Hit, float TimeSlice = 0.f, const FVector& MoveDelta = FVector::ZeroVector) override;
    
  3. Implement HandleBlockingHit function as seen below:

    Super::HandleBlockingHit(Hit, TimeTick, MoveDelta, SubTickTimeRemaining);
    return EHandleBlockingHitResult::AdvanceNextSubstep;
    
  4. Leave HandleImpact function empty




EXPLANATION


Projectile movement component is running TickComponent method to update the motion of the updated component. Each time our updated component hits something, HandleBlockingHit function is executed, which will then return EHandleBlockingHitResult enum type value to decide what to do next with the updated component. The enum value comes basically from HandleImpact function, which by default checks whether the bullet is bouncing or not.

  1. if bullet is not bouncing StopSimulating function will be executed and the updated component will be set to null, HandleBlockingHit will return EHandleBlockingHitResult::Abort value
  2. If bullet is bouncing, HandleBlockingHit will return EHandleBlockingHitResult::Deflect value and will start counting bounces
  3. there is also a third enum value EHandleBlockingHitResult::AdvanceNextSubstep in this enum, specially designed for that case scenario (I assume) as based on the value, hit events are ignored in TIckComponent function.

So when the bullet is meant to move after hit events you would want to return EHandleBlockingHitResult::AdvanceNextSubstep in HandleBlockingHit function. A remark why to leave HandleImpact function empty - you wouldn’t need to use any logic there because the bullet is not bouncing and otherwise it will stop simulating component velocity.



If you have any further questions or you didn’t understand some part of it, feel free to ask.

With regards!

1 Like

Hi , I want to ask a question. if I set the state AdvanceNextSubstep, the hit will ignore. But I don’t see code to reset the EHandleBlockingHitResult, So why the second hit will be check?/(ㄒoㄒ)/~~
Thanks