Is it possible to get the length of a vector while declaring the variable in a function? If so, what’s the terminology/jargon to do it? This is an engine source change but nobody ****** posts or replies in that part of the forums so I’m dropping it here…
Here’s my code, what I want to do is get the length of the hard-coded (Particle.Velocity) vector and store it as “VelocLength” like so:
void UParticleModuleSizeByVelocity::Update(FParticleEmitterInstance* Owner, int32 Offset, float DeltaTime)
{
BEGIN_UPDATE_LOOP;
/* Get the length of the particles velocity vector */
float VelocLength = ;
FVector VelocityScaleFactor = SizeByVelocity.GetValue(Particle.RelativeTime, Owner->Component) * (Particle.Velocity);
Particle.Size = Particle.BaseSize * VelocityScaleFactor;
END_UPDATE_LOOP;
}
I’ll then modify the code to change the velocity scale factor by the vector length, just like the following:
void UParticleModuleSizeByVelocity::Update(FParticleEmitterInstance* Owner, int32 Offset, float DeltaTime)
{
BEGIN_UPDATE_LOOP;
/* Get the length of the particles velocity vector */
float VelocLength = BLAHBLAHBLAH;
float VelocityScaleFactor = SizeByVelocity.GetValue(Particle.RelativeTime, Owner->Component) * VelocLength;
Particle.Size = Particle.BaseSize * VelocityScaleFactor;
END_UPDATE_LOOP;
}
This is done every-frame per particle, so it can’t be TOO computationally expensive. Surely there’s a short-cut way to do it? Oh and of course, the float should be an absolute (positive) value too.