Why is my blueprint acting weird when I try to redirect a projectile upon collision?

Hello, another problem with Blueprints…

What i got: tile-actor with static mesh with collision shape provided, projectile-actor with projectile movement component.

What i try to achieve: tile-actor should redirect projectile upon collision

Hit event is being fired when projectile collides with a tile-actor, hit actor is successfully cast to projectile class projectile’s function that redirects it being called. However, only part of the code is being executed - projectile is being moved according to offsets that simply move projectile to the right side of tile and add some offset to exclude unwanted collision, redirection itself does not take any effect. However, if i redirect projectile in projectile movement component OnProjectileStop event, everything works fine with the same function and the same setup.

Here is the function that redirects projectile:

void AProjectile::Redirect(ATile* Redirector, FVector NewDirection)
{
	FVector RedirectorOffset(0.0f);
	FVector ProjectileOfffset(0.0f);
	FVector FailsafeOffset(0.0f);

	if(Redirector)
	{
		RedirectorOffset = NewDirection * Redirector->ProjectileSpawnOffset;
	}

	ProjectileOfffset = NewDirection * MeshExtent;
	FailsafeOffset = NewDirection * 5.0f; // offset to avoid collision

	SetActorLocation(Redirector->GetActorLocation() + RedirectorOffset + ProjectileOfffset + FailsafeOffset);

	Movement->SetUpdatedComponent(Mesh);
	Movement->Velocity = NewDirection * Movement->InitialSpeed;
	Movement->UpdateComponentVelocity();
}

Code that accesses Movement member is what performs redirection - it simply sets new velocity and registers updated component.


That is what is being executed inside tile hit event. Does not redirect projectile.


This is from projectile OnCollisionStop event, wrapped in another event for easier access in Blueprints. Actually redirects projectile.


Sounds like a total magic… Any help would be nice. Thank you.

The same code does not work in C++, tried redirecting projectile from within tile hit event - same result as with Blueprints based solution.

Checked if projectile collides twice but simulation is resumed only once - nope, only one collision event.

Oh, well, found solution, perform redirection part in separate function with a timer, in other words - i had to do this in another tick, not sure why. Not marking as solved, since i’d like to know why this happens to avoid future issues. Probably because of the way how actor is being moved via SetActorLocation().