How to make Vector3 evenly transition to Vector3.Zero

I know the title is a little confusing, but what I want to accomplish is rather simple. I am aiming to make a Vector3 called velStore(which is used for movement) evenly transition to Vector3.zero. For instance,

velStore.x = 5;
velStore.z = 10;

if velStore.z goes down by 1, velStore.x will go down by 0.5 and repeat this until they become 0. I want to transition rate to be constant, and not slide and go down less near the end of the transition.

Thanks in advance!

You would probably have a function like

ChangeVelZ (float value)
{

float increase = value/velStore.z;

velStore = velStore * increase;

}

Of course you could create different functions depending on if you wanna change x, y or z, or you could have which one to change as a parameter in the function:

ChangeVel (float value, int index)
{

if(index > 2 )
{

Debug.LogError(“Index out of range in ChangeVel”);

return;

}

switch (index)
{

case 0:

float increase = value/velStore.x;

velStore = velStore * increase;

break;

case 1:

float increase = value/velStore.y;

velStore = velStore * increase;

break;

case 2:

float increase = value/velStore.z;

velStore = velStore * increase;

break;

}

}

That’s what Vector3.MoveTowards does.

velStore = Vector3.MoveTowards(velStore, Vector3.zero, 1);

Executing this line once will move linearly towards (0,0,0) by 1 unit in total. Though that 1 unit is 1 unit along the vector, not along one particular axis. Usually when called every frame you would do

velStore = Vector3.MoveTowards(velStore, Vector3.zero, speed * Time.deltaTime);