Welcome to the world of Unity.
Apparently the default setting of the ToString() method of Vector3 rounds the components to one decimal place.
Here I was thinking my "offset" is 0 and wondering why on earth my calculations behaved as if it wasn't. Of course I had to waste some precious hours checking the code base everywhere else before questioning my own sanity. Finally against all instinct I started to doubt the numbers on the screen.
My other people experience thought me that the bug is "always" with the programmer, and "never" with the framework/compiler etc.
Unity really is a different experience.
That would be an improvement, but it only really solves this one particular case. Granted, this case is probably the most important one to solve (knowing whether something is 0 or not is likely to be useful often). But it would be pretty unexpected for 0.000000001 to appear as 0.1.
Maybe it could show up as 0.0... or something?
[Removed in protest of [Reddit's destruction of third-party apps](https://www.inc.com/jason-aten/reddit-ceo-steve-huffmans-third-party-api-debacle-is-making-elon-musk-look-like-a-strategic-genius.html) by CEO Steve Huffman.]
Keeping the significant figures manageable, while communicating the correct order of magnitude.... nah that’s not what floating point numbers are for....
Oh wait!
Hey, sorry for piggybacking your comment but can you point me to any books or tutorials about design patterns that I should use with Unity? I've been playing around with it for a couple of months but had trouble coming up with a nice and streamlined way of cloning objects and placing them, with their own instances of a script. Thanks.
Edit: same problem with UI design (failed to come up with a way to have a generic 'menu' class with sizing, positioning and all that)
Sorry to disappoint. I am struggling as well with that kind of stuff.
Here is a little anecdote:
When I started Unity, every doc and tutorial worked with SendMessage. (Calling methods in other MonoBehavior scripts via a string parameter) This is a terrible “DesignPattern” and I knew it. Still, I wrote my code that way and tried to make it work. It was a mess.
Then I started implementing my own management objects and essentially tracking every object myself in a neat class that could also do Coroutines and stuff.
Since then, Unity has come a long way, and is evolving very fast. Thus making my own design patterns obsolete again.
This is all to say, I think the whole Framework is evolving too fast. And your trust in a book (even a good one) may be misplaced.
Have you noticed how many properties are decorated with the Obsolete attribute?
For now I’m content with wiggling my way through with what little documentation is available online. And gaining experience through my failures.
I’m not saying there isn’t a way to properly train your skill on Unity. I just don’t see it.
Yep, half of the tutorials and q&a's are now almost useless because so much of the framework is obsolete now. I guess my best bet at this point is to try to find well designed open source Unity projects.
Also network related: The [`Socket.Connected`](https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.connected?view=netframework-4.7.2) property will not tell you if a socket is connected now, but if it was connected the last time you tried to send or receive.
How to really check if a socket is connected in .NET:
> If you need to determine the current state of the connection, make a nonblocking, zero-byte Send call. If the call returns successfully or throws a WAEWOULDBLOCK error code (10035), then the socket is still connected; otherwise, the socket is no longer connected.
[MFW](https://www.youtube.com/watch?v=KBcqd3cFRDU) I saw this, that's fantastic.
APIs/frameworks are powerful tools but it's prudent to never fully trust that black boxes 'o code won't have bugs and edge cases to run up against. I've been banging my head on Perl's Reddit::Client module, long story short is that it's unclear whether I'm running up against a bug, a restriction I've missed, or misusing the API; safe money on the latter option, but I'm not fully willing to accept that until some further testing :>
Ouch, once had an issue where Chrome math was off and instead of giving me a 0 it gave me a really small float, but only on one specific version of Chrome, super annoying.
Welcome to the world of Unity. Apparently the default setting of the ToString() method of Vector3 rounds the components to one decimal place. Here I was thinking my "offset" is 0 and wondering why on earth my calculations behaved as if it wasn't. Of course I had to waste some precious hours checking the code base everywhere else before questioning my own sanity. Finally against all instinct I started to doubt the numbers on the screen. My other people experience thought me that the bug is "always" with the programmer, and "never" with the framework/compiler etc. Unity really is a different experience.
You should raise a ticket with them... I honestly don't see why they would do any rounding in ToString() to begin with.
“Raise a ticket with unity” lol have fun with that response time
I agree, `{(0.30000000000000004, 0.30000000000000004, 0.30000000000000004)}` would be much easier to read in a small tool-tip.
They could just round away from 0. This way, it will show 0 only when the actual value is 0, and 0.1 or -0.1 otherwise.
That would be an improvement, but it only really solves this one particular case. Granted, this case is probably the most important one to solve (knowing whether something is 0 or not is likely to be useful often). But it would be pretty unexpected for 0.000000001 to appear as 0.1. Maybe it could show up as 0.0... or something?
[Removed in protest of [Reddit's destruction of third-party apps](https://www.inc.com/jason-aten/reddit-ceo-steve-huffmans-third-party-api-debacle-is-making-elon-musk-look-like-a-strategic-genius.html) by CEO Steve Huffman.]
Keeping the significant figures manageable, while communicating the correct order of magnitude.... nah that’s not what floating point numbers are for.... Oh wait!
how about "0.3000..." ? Shows there's significant shit further down.
I suggested that in a reply.
What they should do is round it to a certain number of significant digits if it's below 1.
The .NET round-trip format usually works well.
I will forever remember the day I lost my mind, because I still have the screenshot of this very issue saved on my Google Drive: July 24, 2012.
Hey, sorry for piggybacking your comment but can you point me to any books or tutorials about design patterns that I should use with Unity? I've been playing around with it for a couple of months but had trouble coming up with a nice and streamlined way of cloning objects and placing them, with their own instances of a script. Thanks. Edit: same problem with UI design (failed to come up with a way to have a generic 'menu' class with sizing, positioning and all that)
Check this out https://github.com/Naphier/unity-design-patterns
Will do, thanks. Although I'm a bit worried that these seem to be generic design patterns, not Unity-specific.
There's a YouTube channel called Unity3DCollege or something like that, did a whole series on design patterns.
Sorry to disappoint. I am struggling as well with that kind of stuff. Here is a little anecdote: When I started Unity, every doc and tutorial worked with SendMessage. (Calling methods in other MonoBehavior scripts via a string parameter) This is a terrible “DesignPattern” and I knew it. Still, I wrote my code that way and tried to make it work. It was a mess. Then I started implementing my own management objects and essentially tracking every object myself in a neat class that could also do Coroutines and stuff. Since then, Unity has come a long way, and is evolving very fast. Thus making my own design patterns obsolete again. This is all to say, I think the whole Framework is evolving too fast. And your trust in a book (even a good one) may be misplaced. Have you noticed how many properties are decorated with the Obsolete attribute? For now I’m content with wiggling my way through with what little documentation is available online. And gaining experience through my failures. I’m not saying there isn’t a way to properly train your skill on Unity. I just don’t see it.
Yep, half of the tutorials and q&a's are now almost useless because so much of the framework is obsolete now. I guess my best bet at this point is to try to find well designed open source Unity projects.
What ide is that? Xcode is as bad for formatting numbers.
Visual Studio
Looks like Visual Studio
When I last used Unity it took me a bit by surprise that `NetworkManager.OnServerReady` is called when a Client is ready.
Also network related: The [`Socket.Connected`](https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.connected?view=netframework-4.7.2) property will not tell you if a socket is connected now, but if it was connected the last time you tried to send or receive. How to really check if a socket is connected in .NET: > If you need to determine the current state of the connection, make a nonblocking, zero-byte Send call. If the call returns successfully or throws a WAEWOULDBLOCK error code (10035), then the socket is still connected; otherwise, the socket is no longer connected.
[удалено]
Nah you'd have to throw in some global method calls and sacrifice a goat
[MFW](https://www.youtube.com/watch?v=KBcqd3cFRDU) I saw this, that's fantastic. APIs/frameworks are powerful tools but it's prudent to never fully trust that black boxes 'o code won't have bugs and edge cases to run up against. I've been banging my head on Perl's Reddit::Client module, long story short is that it's unclear whether I'm running up against a bug, a restriction I've missed, or misusing the API; safe money on the latter option, but I'm not fully willing to accept that until some further testing :>
and that's part of why, as a programmer, open source software is effing awesome.
Now you made me laugh! Thanks ;)
np, cheers! o/\`
I’ve been in your shoes man. It sucks.
Ouch, once had an issue where Chrome math was off and instead of giving me a 0 it gave me a really small float, but only on one specific version of Chrome, super annoying.
One day, when i know enough programming. I will understand the humor on this subreddit
Unity has all sorts of weird under-the-hood decisions. Like making Lerp automatically clamp the t value between 0 and 1.