Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | path9263 |
Lets say I want to modify a bunch of Vector3 variables and I want to change each of their x, y, and z values independently. Right now I have to either write the same code out three times, once for each axis, or create a function and pass into it a whole ton of variables. This isn’t a big deal but it has been bothering me… It seems like there must be a way to do it!
Examples; what I am doing now:
if(foo.x > 5):
bar.x = foo.x
eggs.x += bar.x
foo.x = ham.x
if(foo.y > 5):
bar.y = foo.y
eggs.y += bar.y
foo.y = ham.y
if(foo.z > 5):
bar.z = foo.z
eggs.z += bar.z
foo.z = ham.z
I would love to do something like this but I can’t figure out how to make it happen:
for axis in xyz:
if(foo.axis > 5):
bar.axis = foo.axis
eggs.axis += bar.axis
foo.axis = ham.axis
Thank you!!!