Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What would be the equation to determine the ratio between two Vector3 values?

I am currently working on a script that scales a ParticleEmitter by it's rate, and the size of the emitter's parent.

I am stuck, however, on how to actually find the ratio between the BaseSize (the size of which you use for optimal particle setting), and the CurSize (the current size of the emitter's parent). I am intending to multiply the Rate by the ratio of size difference.


Here is my code, although it does not scale correctly:

local x2,y2,z2 = curSize.X,curSize.Y,curSize.Z
local x1,y1,z1 = baseSize.X,baseSize.Y,baseSize.Z
local size1,size2 = x1*y1,x2*y2
local multiplier = size1/size2
print(multiplier)

for _,v in pairs (emitters) do
	v.Rate = v.Rate*multiplier
end

Thank you!

1 answer

It's still bit tough to understand what exactly you want, but I assume you'd like to have some base emission rate for the 'BaseSize' and then scale it accordingly, depending on the actual part's size.

I think it could work by simply taking the magnitudes and dividing them, since you didn't mention about whether it should be reacting only to specific axis.

So basically it would look like: CurrentSize.magnitude / BaseSize.magnitude

The final result could look like this:

local multiplier = currSize.magnitude / baseSize.magnitude
print(multiplier)

for _,v in pairs (emitters) do
    -- Probably would be a good idea to store the base rate so it doesn't change unexpectedly
    v.Rate = v.Rate*multiplier
end

1 comment

0

Thanks! I'll try that later. For ease of use, I just make the BaseRate = v.Rate.

This discussion is preserved as it was. New answers, comments, and votes are closed.