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.