Page 1 of 1

Wrong old Particle spawning method

Posted: Sat May 12, 2018 5:40 pm
by OrkhanAliyev
When i spawn a particle by using C++, my launcher(not editor) just crashes after i re-spawn. Does anybody knows why?

The way i use is:

Code: Select all


// particle 1 vars
bool canStartLoadAction = false;
bool canStopLoadAction = false;
IParticleEffect* informationWeaponLoadingParticle;
IParticleEmitter* pEmitterA = NULL;
Vec3 informationWeaponsLastPosition = ZERO;
Quat informationWeaponsLastRotation = ZERO;
//
CSpammer spammerLoadingCall;

void CBlaBlaBla::Update(SEntityUpdateContext& ctx, int slot)
{
if (!gEnv->IsEditing())
{
// Information Weapon Particle World Pos
Vec3 iWPWPos = GetEntity()->GetWorldPos();

if (pEmitterA)
{
if (informationWeaponsLastPosition != GetEntity()->GetWorldPos() || informationWeaponsLastRotation != GetEntity()->GetWorldRotation())
{
pEmitterA->SetLocation(QuatTS(GetEntity()->GetWorldRotation(), (GetEntity()->GetWorldPos())));

// Then update these
informationWeaponsLastPosition = GetEntity()->GetWorldPos();
informationWeaponsLastRotation = GetEntity()->GetWorldRotation();
}
}

//CryLogAlways("goes");
// TODO: OPTIMIZE THIS CODE!

if (spammerLoadingCall.spammerLoading)
{
// Don't let check this condition too many times
if (canStartLoadAction)
{
//CryLogAlways("spammerLoadingCall");
canStartLoadAction = false;
canStopLoadAction = true;

informationWeaponLoadingParticle = gEnv->pParticleManager->FindEffect("blabla_weapons.information_weapon.loading_a");
if (informationWeaponLoadingParticle)
{
// SPAWN PARTICLE IN ANY CASE.

//informationWeaponLoadingParticle->AddRef();
if (!pEmitterA)
{
pEmitterA = informationWeaponLoadingParticle->Spawn(false, IParticleEffect::ParticleLoc(iWPWPos));
}
else
{
pEmitterA->Hide(false);
}

}
//

//CryLogAlways("LoadingsStarted");
}
}
else
{
canStartLoadAction = true;
//CryLogAlways("IsNotLoading");
if (canStopLoadAction)
{
if (pEmitterA)
{
pEmitterA->Hide(true);
}
canStopLoadAction = false;
//CryLogAlways("LoadingsStopped");
}
}
}
}
}


Re: Wrong old Particle spawning method

Posted: Sun May 13, 2018 8:28 am
by fury22uk
Why don't you debug it?

Re: Wrong old Particle spawning method

Posted: Sun May 13, 2018 4:21 pm
by OrkhanAliyev
I found the problem, but could not solve it.

When i make particle emitter equal particle effect's spawn, it saves it in memory. When i back to main menu in launcher, load my level and call that function again, it can't find the particle in the level saved in memory before. For this reason, it just crashes because it checks parameter of something that does not exist.
In brief, the problem is about resetting variable value.

I'll try to reach my problem's solve in any case.