C# How can create a list of floats from different types of structs?
For the project I'm currently working I keep running into an issue where float values return in the negative. I've got a block that can convert them to positives.
public float positivefloat(float num1)
{
float result;
if (num1 < 0)
{
result = num1 * -1;
}
else
{
result = num1;
}
return result;
}
The issue is that i still have to type "positivefloat("variable name"); for each individual float i need in the positive. so if i have a Vector2, Vector3, or Quaternion, I have to reference each axis manually.
How would i go about writing a method to check to see which type the reference is(float, Vector2, Vector3, Quaternion) and pull all of the corresponding axis floats into a list. then use a foreach to execute positivefloat on each item in the list, then return the list in all positives?
Your answer
![](https://koobas.hobune.stream/wayback/20220612214717im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Having trouble with Vectors 1 Answer
Vectors side determing by a line. Please help me out !!!! 0 Answers
Need some help programming basic AI movement 0 Answers
Spawning collections of objects based on spawned center points 0 Answers
Moved GameObject under Canvas (Parent), transform.position vector coordinates mismatch 0 Answers