10:00am - Weird, I was all worried about getting to the library too early, and here I am sitting down an hour after they open. Oh well.
Working on the Estheria Prototype again today. Targeting the mechanics I outlined yesterday.
10:16am - Bit of a track jump; I realized that the way I was handling input wouldn't work with AI; if it's checking an InputHandler for input reveals, it won't be checking an AI system for what to do. So instead I'm going to have the InputHandler directly tell the Mobile components what to do.
I don't like it, though. Hmm... The problem is that they could either be an InputHandler or an AIModule. Could this be a case for polymorphism? I could make a base class that reveals the input properties, and subclass it into InputHandler and AIModule, and then AIModule into whatever sorts of AI Modules I want to implement. That way the other components on a mobile could look for the revealed properties on a, let's call it ControlModule, and it wouldn't matter that it was a different class than the base class if it inherits from it.
Hmmm.... This brings up a new problem though. Normally when you've got just one copy of a component on an object you can simply do GetComponent() to get the instance. This way, every one of the other components on the object would need to have their ControlModule injected in the inspector. I'm not sure if that's better or worse than having the InputHandler or AIModule polling the object to see what components it has, and taking control of them.
Oh and I just realized something! If I do it by way of the injection, what happens if a Mobile needs to switch between Player and AI Control, like for a cutscene or for switching your main character?
I guess that puts me back into having the InputHandler and AIModules grabbing all the other components and controlling them directly. That way I can turn one or the other off as needed.
That's rather roundabout, returning to where I started, but at least I considered the other idea and figured out what problems it would have instead of just implementing it.
10:37am - I'm also changing the InputHandler class name to PlayerInput so it's clear that it's not a generic input anymore.
10:55am - Okay we've got movement rebuilt. Now for the Dialogue...
10:59am - Alright so there'll be a MobileInteract component on the player and probably on NPCs as well, allowing them to interact with interactables in their environment. Most importantly this'll be the player talking to NPCs.
But the code I had for wasn't good enough. It didn't determine facing; it automatically resets the player to an idle pose facing down, and it uses the player's movement input to determine their facing. If the player stops pushing towards the NPC then they won't be able to talk to them. So, I need to determine and reveal facing somewhere.
I'm thinking of making it a public property on the MobileMover so that the MobileInteract can read it, but that will couple the two components a little. It should be okay as long as the MobileInteract checks to make sure there's a MobileMover before it tries to read the value, though.
The alternative would be to make the MobileInteract track facing on its own, but I don't think it'll be the only component that wants to know what direction the mobile is directed.
One problem I've still got though is how to determine which direction the mobile is facing. When it's got input it's obvious, but I'm not sure how to recognize when the facing direction changes. Hmm...
Maybe if the facing only changes when the input flips from positive to negative? That way it'll track the last positive input while ignoring zero inputs. I'll try that.
11:29am - No, that won't work. That only gets me the four diagonal directions. Hmm...
11:52am - I tried looking for other people who had this problem and I found a solution. Constantly save a 'previous direction' and when the input is zero, the facing will be the last direction the player looked. That makes sense.
11:56am - Huzzahulations! The facing works and all it took was one line of code. XD
Feeling good, but also hungry. I've only been here two hours. ^.^;;
I'll try to squeeze in one more hour before I go for lunch.
So anyways now that I've got my facing, the MobileInteract needs to know what sort of interaction system I'm going to use. Previously, I had set it up by searching for a DialogueEvent component on a Raycast hit target, but I want my interactions to be more generic. So I came up with an idea while I was thinking about this. I'll make an Interactable component for it to search for, and the Interactable component will have one public property, a Delegate! That's kind of a function pointer in C#. Depending on what the interaction does the delegate could point to anything. Hopefully this works. I'll have to test it out.
1:02pm - Alright I've got the interaction working. Right now all it does is have a test object do a debug.log call, but next I'll rework the dialogue system to be called by the interaction, and do my baton pass.
But first, lunch.
Working on the Estheria Prototype again today. Targeting the mechanics I outlined yesterday.
10:16am - Bit of a track jump; I realized that the way I was handling input wouldn't work with AI; if it's checking an InputHandler for input reveals, it won't be checking an AI system for what to do. So instead I'm going to have the InputHandler directly tell the Mobile components what to do.
I don't like it, though. Hmm... The problem is that they could either be an InputHandler or an AIModule. Could this be a case for polymorphism? I could make a base class that reveals the input properties, and subclass it into InputHandler and AIModule, and then AIModule into whatever sorts of AI Modules I want to implement. That way the other components on a mobile could look for the revealed properties on a, let's call it ControlModule, and it wouldn't matter that it was a different class than the base class if it inherits from it.
Hmmm.... This brings up a new problem though. Normally when you've got just one copy of a component on an object you can simply do GetComponent
Oh and I just realized something! If I do it by way of the injection, what happens if a Mobile needs to switch between Player and AI Control, like for a cutscene or for switching your main character?
I guess that puts me back into having the InputHandler and AIModules grabbing all the other components and controlling them directly. That way I can turn one or the other off as needed.
That's rather roundabout, returning to where I started, but at least I considered the other idea and figured out what problems it would have instead of just implementing it.
10:37am - I'm also changing the InputHandler class name to PlayerInput so it's clear that it's not a generic input anymore.
10:55am - Okay we've got movement rebuilt. Now for the Dialogue...
10:59am - Alright so there'll be a MobileInteract component on the player and probably on NPCs as well, allowing them to interact with interactables in their environment. Most importantly this'll be the player talking to NPCs.
But the code I had for wasn't good enough. It didn't determine facing; it automatically resets the player to an idle pose facing down, and it uses the player's movement input to determine their facing. If the player stops pushing towards the NPC then they won't be able to talk to them. So, I need to determine and reveal facing somewhere.
I'm thinking of making it a public property on the MobileMover so that the MobileInteract can read it, but that will couple the two components a little. It should be okay as long as the MobileInteract checks to make sure there's a MobileMover before it tries to read the value, though.
The alternative would be to make the MobileInteract track facing on its own, but I don't think it'll be the only component that wants to know what direction the mobile is directed.
One problem I've still got though is how to determine which direction the mobile is facing. When it's got input it's obvious, but I'm not sure how to recognize when the facing direction changes. Hmm...
Maybe if the facing only changes when the input flips from positive to negative? That way it'll track the last positive input while ignoring zero inputs. I'll try that.
11:29am - No, that won't work. That only gets me the four diagonal directions. Hmm...
11:52am - I tried looking for other people who had this problem and I found a solution. Constantly save a 'previous direction' and when the input is zero, the facing will be the last direction the player looked. That makes sense.
11:56am - Huzzahulations! The facing works and all it took was one line of code. XD
Feeling good, but also hungry. I've only been here two hours. ^.^;;
I'll try to squeeze in one more hour before I go for lunch.
So anyways now that I've got my facing, the MobileInteract needs to know what sort of interaction system I'm going to use. Previously, I had set it up by searching for a DialogueEvent component on a Raycast hit target, but I want my interactions to be more generic. So I came up with an idea while I was thinking about this. I'll make an Interactable component for it to search for, and the Interactable component will have one public property, a Delegate! That's kind of a function pointer in C#. Depending on what the interaction does the delegate could point to anything. Hopefully this works. I'll have to test it out.
1:02pm - Alright I've got the interaction working. Right now all it does is have a test object do a debug.log call, but next I'll rework the dialogue system to be called by the interaction, and do my baton pass.
But first, lunch.