Hi everyone!
I am spawning a cascade blood particle emitter on a moving AI. The particle seems to collide with the floor due to the delegate’s function being fired off on particle collide. Yet it seems only when the particle emitter collides while very close to the floor does the decal spawn. I am using CPU related particle emitters not GPU related particle emitters.
I have unchecked the options in the performance settings of the emitter, I have unchecked local space on all of the emitters, I have checked the collision of the floor relative to the the actor collision of the particle emitter. I have an event dispatcher within the particle emitter and I have actor collision as well.
For some reason the particle emitter only spawns a decal when it is near or pointblank next to the floor. Here I am spawning the emitter via multi line trace:
if (ANPC* Enemy = Cast<ANPC>(Results.GetActor()))
{
if (BulletSplashHit)
{
UParticleSystemComponent* ParticleSystem = UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), BulletSplashHit, FTransform(Results.ImpactNormal.Rotation(), Results.ImpactPoint));
TScriptDelegate<FWeakObjectPtr> Delagate;
Delagate.BindUFunction(this,"OnParticleCollide");
ParticleSystem ->OnParticleCollide.Add(Delagate);
}
}
Here are the functions called by the event.
void AWeapon::OnParticleCollide(FName EventName, float EmitterTime, int32 ParticleTime, FVector Location, FVector Velocity, FVector Direction, FVector Normal, FName BoneName, UPhysicalMaterial* PhysMat)
{
if (BloodDecal)
{
//I recorded multiple hit locations using this UE_LOG.
UE_LOG(LogTemp, Warning, TEXT("DecalLocation: %s"), *Location.ToString());
//The log fires off multiple times indicating multiple impacts.
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan,
FString::FString("Blood has collided."));
//Decal only spawns once and only when the emitter is point blank relative to the floor.
UGameplayStatics::SpawnDecalAtLocation(this, BloodDecal, FVector(50.0f,
50.0f, 50.0f), Location, Direction.Rotation(), 10.0f);
}
}
A decal does in fact spawn but not in the way you would expect. The functionality of the particle emitter seems bugged. Multiple decals don’t spawn when the droplets of the particle emitter collide with the floor. When the particle emitter is right next to the floor itself that is the only time when the decal itself spawns. I don’t know if it is the rotation of the decal that I am spawning or it is the particle emitter’s settings. I also printed a UE_LOG() of the decal’s spawn locations and the function returned multiple XYZ coordinate values. I set the particle emitter to freeze the particles on collision and the particles freeze on the mesh or capsule component I don’t know which.