- Home /
Whats the float in Vector . Distance?
Is the float returned in meters for Vector distances? I'm trying to make an rts grid and want to make a visual grid in photoshop for the player to see where he can build.
I'm also making a Tile system in c# code and trying to figure out how to make the texture lines on the terrain match the tile sizes in code.
Some Unity systems use meters as the default unit of measurement (e.g. physics), but as others have said, it's up to you. But if your scale isn't meters you may need to change some parameters, like gravity.
Answer by rutter · Sep 12, 2014 at 08:03 PM
Whatever unit you use while building your game, that's the same unit you'll get out of Vector3.Distance
.
Drop and object at (0,0,0) and move it to (0,0,1). How far did it move? 1 unit. What unit? That's up to you.
The math doesn't actually care what your units are; the formula is the same for feet, centimeters, feet, or miles. Most Unity developers treat 1 unit as 1 meter, in part because the physics engine defaults are calibrated for that, but it's ultimately up to you whether or not to follow that convention.
Answer by kacyesp · Sep 12, 2014 at 08:02 PM
The measurement is Unity units, which for me is 100 pixels to 1 Unity unity. You also might want to try to think of an alternative to the distance function because it uses the magnitude function which is very slow because it uses square root.
Your answer
Follow this Question
Related Questions
RTS camera help 1 Answer
focusing on a unit during unit detection in an RTS 1 Answer
Best solution for Grid-based building system? 0 Answers
RTS Movement and grid questions 0 Answers
local avoidance question 0 Answers