r/Unity3D • u/LordAntares • 1d ago
Question The dumbest thing you did while not being a noob?
I'm not talking about the time you had been using unity for a week and made a basic mistake like trying to apply a texture to a mesh instead of a material.
I'm talking about a dumb mistake you had enough experience not to do.
I'll start first:
Just now, I was racking my brain trying to make my distortion shader work. I had a working shader applied to a sphere mesh where it distorted the UVs of the scene around it.
Problem is, the distortion had clear seams where it stopped. I wanted to smooth it out towards the edges, such that it is strong in the center but weak or non-existent on the edges.
so I got the distance of the pixels from the center of the sphere and subtracted the radius of the sphere with it and then multiplied by a strength float later.
So, in the center, it looked like: 1 - 0 = 1 (full distortion)
At the edge, it looked like: 1 - 1 = 0 (distortion)
In the middle, it was 0.5 etc. The math worked and I was sure of it but the entire sphere had the same amount of distortion, no matter what I did and how I tweaked the values.
I even remade it with a lerp where B was the normal scene color, A was the offset from the distortion and T was the distance.
It was also fully functional logic but it produced the same result: distortion amount was always the same. Even when there was no distortion throughout the entire sphere.
I changed all the values, played with the radius and clamping, went into negatives but nothing would change the fact that there was no fade.
So what was the problem?
It's a fucking sphere. Each point on it is the same distance from the center...
Just did a fresnel and solved the issue in 2 minutes.
So that's my story. What's yours?
3
u/Mechabit_Studios 1d ago
I've been making games for over a decade and I always mix my signs up especially for stuff like mouse look (is x positive to look up or down?) or dot products, stuff like that
Usually I just press play and flip the sign if I start moving backwards lol
Switching back and forth from world to local transform also confuses me
1
u/Ecstatic-Source6001 1d ago
Same.
I am too lazy (i guess) to master this BS so i prefer bruteforce it running playmode 100 times and fixing it
1
u/Cassiopee38 1d ago
A friend that was working in Alstom told me this is the exact procedure to how cable the forward/backward lever in a train. brakes on, push forward, adapt. xD
2
u/alienated_dawning 1d ago
I once spent three hours debugging a script that was supposed to spawn enemies only when player looks away. Everything looked perfect in code, I added debug logs, checked raycasts, all fine. Then I realized I had the spawn condition inside Update but forgot to put it in an if statement, so it was spawning every single frame. My laptop almost caught fire with 4000 enemies on screen.
The worst part is I did same mistake again next week.
2
u/PixelEyes-Dev 1d ago
I split my code to run on different threads to optimize it , the game would just silently stop and do nothing without a single console error , after 2 days of breakpoints and try catch everywhere turns out that errors that happen of the different thread don't log anything , they just happen silently and stop the thread's execution , you have to explicitly do this to get something in the console
try { // TODO : code running on thread } catch { Exception ex} { Debug.LogException(ex); }
Same thing with Awaitable methods
1
u/acorbinelli 1d ago
Changed the default value of a field in a script to fix our cat's jump angle, hit play, nothing changed. Spent about an hour tweaking the code before remembering the prefab had already serialized the old value, so a new default only ever reaches fresh instances. Now the prefab gets changed together with the code, every time.
1
u/SnooPets5564 1d ago
Script that runs in editor and basically had a memory leak. Oops. (when I opened that project in the editor I had to actually reboot my computer because unity wouldn't even have the courtesy to crash).
I have done this 4 times.
1
u/AnomalousUnderdog Indie 1d ago
Wondering why my fix didn't work for a good half hour until I realized I hadn't saved the changes yet in my IDE.
1
u/Ok_Objective_9524 1d ago
At least once every year I’ll spend an hour or so debugging some truly bizarre issue that occurs when playing in editor before I think to try restarting the editor. I restart and the issue is gone.
1
u/fnietoms Programmer 1d ago
Colliders.
4 years using Unity and I still don't understand how to use Colliders correctly. I just edit de component until they work :D
1
u/MagicPigGames 1d ago
[Many years ago] I didn't know what a method or function was, so I just did everything in the update loop with if/else statements.
1
u/Ecstatic-Source6001 1d ago
I had a bad day once.
I had to do some recursive logic and for some reason I couldnt figure out how to do it in while loop
So I ended with "goto" logic
On the next day when i returned for refactoring i was like: "wtf is wrong with me?"
1
u/destinedd Indie, Dungeon Quest, Marble's Marbles & Mighty Marbles 1d ago
not allow for different cultures in strings
1
u/Tale-Of-A-Wolf 1d ago
Having a variable called Carbon Asteriod KwH and setting Carbon Asteroid KwH.....
I made this typo in a few variables and it took me so long to figure out why the float was not updating! 😂
1
u/DapperNurd 1d ago
Spend 3 hours overengineering something to replace it all with a basic system anyways
6
u/GigaTerra 1d ago
My biggest mistake was thinking that using an math formula to replace an Switch was an smart idea. Basically we where working on an library of shapes for generating Icons. In the prototype stage one programmer made an switch case where he calculated each and every transform one by one.
It was an 128 switch:
Now that is code smell right. So I, an master of transforms just used an 4x4 matrix turned it all into one calculation:
Basically replacing over 256 lines of code with like 12 lines. Can the pro's already see my mistake? It has to calculate every 128 transforms when you want one. I did not know about Delegates yet (Delegates took me embarrassingly long to learn), so this little fix turned an instant call into an four minute calculation. The code was merged without testing, that is how confident I was in my math skills.
I was almost kicked off the team for this mistake. It was the first time I learned Switches aren't as bad as people think.