- Home /
Question about C# parameters
Which one of these would be a better set of parameters:
(Vector3 pos) or (int x, int y, int z)
Answer by ShroomWasTaken · Jan 29, 2018 at 04:24 PM
I guess it depends on what you want to do, but generally in unity I use Vector2/Vector3 since they're a part of the API and there is usually no need to send in the values individually.
If I specifically want a Vector3 or Vector2 to be int values I just round/cast the x, y and z to int.
Answer by yummy81 · Jan 29, 2018 at 04:43 PM
When you want some sort of precision (velocity, distance, position, scale, etc.), use Vector2 or Vector3. These two structs work with floats. On the other hand if you want to, let's say, create some kind of tilemap, the better choice would be Vector2Int or Vector3Int. Vector2Int and Vector3Int work with ints.
Oh wut, I didn't even know integer vectors existed in Unity. How have I not seen this before...
Your answer
Follow this Question
Related Questions
How to use PerformanceCounter(C#) in Unity 0 Answers
PerformanceCounters return 0MB RAM and %100 CPU in Unity 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
WorldToScreenPoint in Update/OnGUI: Bad Performance 1 Answer