All I want to do is make a simple block placement validator which is impossible when Unities location accuracy is almost as bad as their answer/forums community.
Additionally, here is some very odd behavior.
public static void SectionPlaced(GameObject mazeTile)
children = mazeTile.GetComponentsInChildren<SectionValidation>();
foreach (SectionValidation sectionValidation in children)
Debug.LogError("placed two sections in same spot");
Vector3 a = sectionValidation.gameObject.transform.position;
Vector3 b = new Vector3(Mathf.Floor(a.x), 0, Mathf.Floor(a.z));
//this is the gameobject
sectionValidation.gameObject.transform.position = b;
is almost as bad as their
First off, you’re generally not liable to get assistance with your problem when you badmouth the community you’re seeking help from.
Lucky for you, it happens to be an interesting (if still commonly seen) subject.
In short, float
ing point numbers aren't a replacement for int
egers. They're not really comparable to int
egers, in the sense that (computer) math is performed in a very different manner on them. Compounded on this, 32-bit float
values will have even less precision allotted to them, that they will easily not land *exactly*
on an int
That is only partially related to your image examples, however.
Unity’s implementation of Vectors (Vector2/3/4), when calling ToString(), rounds the decimal places of their component floating point values to the nearest tenth (i.e. single decimal place).
For reference, Debug.Log() implicitly, automatically converts anything that isn’t already into a string using any available ToString() function.
You demonstrate no awareness for basics of computer science and that is ok. Everyone starts somewhere, everyone has his Achilles’ heel; totally fine.
But please make sure your question is polite enough not to be mistaken for a rather unpleasant person.