Work Post

Dec. 7th, 2017 12:56 pm
relee: Picture of Relee Starbreeze, Wizard (Default)
[personal profile] relee
12:56pm - I finally managed to stay up late enough to enjoy the call with my friends, which means getting up later and working later, but here I am.

Anyways as I recall the last thing I was working on was fixing up the DialogueInput component so that it could move the cursor on dialogue choices.

1:19pm - I accidentally opened Steam and it had some interesting ads that interested me so I got distracted, but I'm back, and I got that DialogueInput working. So now the game is back to the state it was in when I started tweaking it, only much better structured.

Next I'm thinking of adding scene transitions.


1:34pm - Let me try and round up the things I need to add for this game scaffolding to be feature complete.

A Start Page
An in-game Menu
Scene transitions
JRPG style battles?

Really I think I need to know more about what Zax wants before I can solidify this design into something.

But at least I can make scene transitions.

The basic scene transition is going to be a trigger and when the player enters it they're automatically taken to another scene.

1:58pm - Just back from a bio-break. I realized that there's a flaw with my scene transition plan in that while a basic scene transition from level to level is easy, multiple scene transitions between different areas is much more complex. Like if I have a town for example, and there are multiple indoor areas, how does it know which door to put you at when you return to the town scene?

They actually addressed this problem in a Unity tutorial I saw recently, so I'm going to watch that and see how they handle it.

2:27pm - Geez, there are a lot of weird functions in Mathf. I had no idea about Approximately or MoveTowards.

2:45pm - Huh, it looks like after all that they didn't have time to cover the part I'm concerned about. Well I thought up an idea for it anyways. Actually, a few ideas.

The first idea is to make a ScriptableObject and set it with the name of the last scenetransition used. Then when a scene loads it uses that information to choose the spawn point for the player. That'll require the level designer to put the name of the scenetransition into the spawn point in the other scene. It's pretty simple.

The second idea is to make a ScriptableObject for each Scene and have it ... um... Actually I forget the second idea.

So I guess it's the first idea to the rescue!

I'll need to make a SpawnPoint to go along with the SceneTransition, and also a LastSceneTransition scriptable object.

Hmm... This is getting dangerously close to another singleton manager; but I need something that persists between the scenes to track the last scene transition, and it has to be connected to all the scene transitions and spawn points universally...

I could make it globally available, but that violates my design architecture. So I'll have to inject it into each of them.

3:01pm - Oh I'm remembering the second option. There's a problem with the basic SceneTransition in that each of them cause the transition themselves, without warning anything else. So the scene gets unloaded and any changes are lost. So, a potential solution to that would be to have a SceneManager ScriptableObject that has a method for switching scenes, and which informs all interested parties before and after loads with an event system. This could contain the LastSceneTransition data as well. The problem is it's a detatched, universal manager sitting in a ScriptableObject. :/

3:27pm - Hmm... I tried downloading the project that those guys were making to see if they included spawn points but it doesn't look so. There seems to be some code for them in there but they don't seem to actually be in the world, and their method is pretty weird. They used a whole other scene in the background that was constantly active to store data. I'm trying to keep just one scene active at a time.

Hmm... As long as I'm injecting the big SceneTransitionManager into every object that requires it, then I'm not using a singleton, but it still comes with dependancy problems. All the transitions will need it in order to work.

Well it's the only way I can think of to properly warn all the interested parties before and after a scene change, so until someone comes up with a better way I'll have to do it this way.

3:47pm - Oddly I'm losing interest in this and having trouble focusing. Well, I guess I have been at it for almost three hours. Maybe it's time for a break.

4:43pm - Alright, it's about an hour later so I'd better get back into it if I'm gonna.

6:00pm - I worked a bit and then ate and now I'm not sure what to do with myself. I don't know if I'm bored with my work or just have other things on my mind but I don't feel like working right now. The frustrating thing is that like always I don't think there's anything that feels more worthwhile than my work, and I don't really feel much like doing anything else.

I mean, I'd kind of like to talk with some folks about transhumanism and my 'exploring the virtual space inside a jupiter brain' idea. But I'm not sure what to do with that regard.

6:11pm - I just realized there was a big hole in my logic. I was going to make the script for spawn points for transitions and I realized that there was nothing to script. All I need for a spawn point is an empty game object and it's transform. But how will the transition know which spawn point to drop you at? I was thinking that I'd need to know the last transition name so that I could tell the next scene to spawn the player in the matching location, but I should be sending the name of the spawn point instead!

Alright I'll recode to do that and get rid of this superfluous extra class.

6:39pm - Oh, geez, how did I not notice this sooner? You can't run a coroutine from within a ScriptableObject; it doesn't have an update method. This makes the whole thing fall apart. Shoot...

I could put it on an object set to DoNotDestroyOnLoad but then it would ruin the whole idea of each scene being independant. Each scene would need a copy of it present to load. I'd have to make it a singleton so that there's only one in the scene. It's all the way back to zero that way.

Hmm...

Maybe if I keep the events on the ScriptableObject and put the Scene Transition back into SceneTransition, and had it call the events instead?

6:59pm - Okay I've changed it so that the events are handled by SceneTransitionManager but they're triggered by any SceneTransition. I also fixed up the SceneTransition so that it takes the name of a Spawn Point and puts that in the SceneTransitionManager for targeting.

Now I need to write a component for the player such that if there is a SpawnPoint listed in the SceneTransitionManager, and that SpawnPoint exists in the scene, the Player is moved there at the start of the scene.

7:41pm - Man I must be tired, that took me way too long to figure out. I'm waiting on code that won't execute because it comes after the scene was unloaded. Hmm...

7:51pm - I'm not sure what to do now. I tried opening the new scene while the old scene was open and that made a whole mess of problems. The best thing I can think of now is making a "SceneTransitionDetector" and putting one in every scene, and when the scene transitions it runs the SceneTransitionEnd method on the SceneTransitionManager. But that's just making everything more complicated!

I'm not sure what else to do though so I'm going to do it. Then I'm going to go home, and hope I come up with a better idea next time.

8:00pm - Pffft. I just tried looking up a way to determine if the scene was just loaded, I thought there was but as it turns out there's actually already delegates in the SceneManager class. I'm going to try using them instead.

8:08pm - And it works, and it means that my SceneTransitionManager just lost its event calling job. All it does now is hold the name of the target SpawnPoint. Well, it still has a bunch of code. I'll clean it up next time.

I need to go home.

Profile

relee: Picture of Relee Starbreeze, Wizard (Default)
Relee Squirrel

July 2023

S M T W T F S
      1
23456 78
9101112131415
16171819202122
23242526272829
3031     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 24th, 2025 03:13 pm
Powered by Dreamwidth Studios