Hi. I have problem with particles. Right one is empty blueprint with only static mesh and particle system. Left one is c++ based projectile with mesh and particle system. Projectile blueprint is fully empty.
When i start simulate or play particles are disappear.
I almost brake my brain. Please, help.
Projectile code:
ADIMPProjectile::ADIMPProjectile()
{
// Make projectile replicate its position from server
bReplicates = true;
bReplicateMovement = true;
Collision = CreateDefaultSubobject<USphereComponent>(TEXT("Collision"));
Collision->OnComponentBeginOverlap.AddDynamic(this, &ADIMPProjectile::OnBeginOverlap);
RootComponent = Collision;
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Mesh->AttachTo(RootComponent);
//RootComponent = Mesh;
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovement"));
ProjectileMovement->InitialSpeed = 10020.f;
ProjectileMovement->MaxSpeed = 10000.f;
ProjectileMovement->bRotationFollowsVelocity = true;
ProjectileMovement->bShouldBounce = false;
Damage = 0;
Instigator = NULL;
}
// Should be common to all projectiles, so should be made static later
void ADIMPProjectile::BeginPlay()
{
}
void ADIMPProjectile::DestroyEverywhere_Implementation()
{
Destroy();
}
bool ADIMPProjectile::DestroyEverywhere_Validate()
{
ALWAYS_VALIDATE;
}
void ADIMPProjectile::NetMulticastDestroy_Implementation()
{
Mesh->SetHiddenInGame(true);
Collision->SetCollisionEnabled(ECollisionEnabled::NoCollision);
SetLifeSpan(0.5f);
}
bool ADIMPProjectile::NetMulticastDestroy_Validate()
{
ALWAYS_VALIDATE;
}
void ADIMPProjectile::OnBeginOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (isExplosive) {
Explose();
}
else {
if (OtherActor && (OtherActor != this) && (Instigator && (OtherActor != Instigator)))
{
// It evaluates to true, if collided actor is present, and the collided actor is not self,
// and if we have set instigator pointer, it skips instigator
// It's very important to make last check, because when projectile is created,
// it can immediately collide with the instigator and disappear
FPointDamageEvent PointDmg;
PointDmg.ShotDirection = GetActorRotation().Vector();
PointDmg.Damage = Damage;
OtherActor->TakeDamage(PointDmg.Damage, PointDmg, (Instigator) ? Instigator->Controller : NULL, this);
//UE_LOG(LogTemp, Warning, TEXT("DESTROY!"));
Destroy();
}
}
}
void ADIMPProjectile::SetInstigator(ACharacter* NewInstigator)
{
Instigator = NewInstigator;
}
void ADIMPProjectile::SetDamage(float NewDamage)
{
Damage = NewDamage;
}