Day 59: Today I got stuck on a problem. You know the kind of stuff you think should take 5 minutes but ends up taking most of your day? That was really frustrating, so describing this will most likely take a major part of today’s post. And since it’s Friday and I can’t wait to play Skyrim, let’s get this done quickly. Today I:
Did a screen shake feature. Coding it was fun. Using it not so much. It’s hard for me to do this kind of stuff. It’s too visual, I can code a script that enables you to tune the screen shake super easily. But tuning it myself so that it feels good, that’s not what I’m really good at. But I still managed to get something good enough. The script has a list of different screenshake settings. so that I’m sure each shake is good and I don’t have hundreds of different shakes because each call sends a different parameter. The configuration includes: duration, intensity and a tween curve. They are ordered in a dictionary by a type enum. The shake script then listens for events that calls for a shake and launch the appropriate one.
Got stuck on updating enemies in the rooms. In Unity there is no nested prefabs. So since I save enemies in rooms, all connection to the original prefab is lost. But I thought it was no big deal. During the tool sprint, I did a tool to iterate on all the rooms and update by code the enemies. And it worked well. So today, I thought all I had to do to fix a bug was to enable multi selection with this tool. I was wrong, so wrong. I did multi selection. Then since I was sure of me I ran it. It fucked up all the enemies configurations. That was two days worth of work that was ruined. Thankfully I use git and revert the changes didn’t took long. But the problem remained there. WHY does this script that worked perfectly now fucks up my whole project? Naturally I thought this was because of the multi selection. After all it was the only thing that changed… But no, it wasn’t that. I have no idea why but today the script that work perfectly before got Unity completely mental. I encountered so many weird things. Like a difference between the Scene inspector and the assets inspector. And of courses crashes. A lot of crashes. So after struggling in incomprehension for two hours, I did what any sane man would do. I started doing big changes hoping the problem would be comprised in the things changed. And it was. I rewrote all the custom Tiled importer. I did this because I use Tiled2Unity. I have the possibility to modify the imported prefab. The problem is that any modification on the prefab after triggers a re-import. It’s slow and not useful in many cases. So I modified my custom code to create a copy of the Tiled object and put it in my intended prefab in another folder. It was only this that I understood what drove Unity crazy. It was because to modify a prefab, I destroyed and added GameObject directly in the asset. What I do now instead is I create the appropriate object in the scene. Then I replace the prefab with that object (PrefabUtility.ReplacePrefab). Once I understood that. All I had to do was to completely rewrote the enemy update tool. And it works now! I beat this satan-level bug! It’s awesome right? No. It takes way too long… replacing each enemy in every room is awfully long. There’s like 5000 enemies… So maybe it’s just a bad idea to hack my way toward “nested” prefabs. I think I need to get back to the previous solution for the enemies configuration: Storing a ref to the enemy, a position a rotation. And instantiate them at start. This is more complicated, but the solution I have now is not efficient enough. Anyway, it works for now. I just spent almost all my day doing something absolutely invisible for the player. And that, while I only have 4 work days left before showing it to IndieCade…
0 comments