Wrong old Particle spawning method

#1
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

#3
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.

Who is online

Users browsing this forum: rndlab and 3 guests