Interactions: Divorced Logic
What's the Plan?
Originally, I was going to dive into my savegame manager today. But, with it being Friday and all the things that means, I decided I wanted to tackle something a little less complicated. So I'm diving back into my player character (sort of) and my interactables. Earlier today, during a work meeting, I had a discussion with Gemini about what I wanted to accomplish. I need to move some of the targeting logic out of the player character and into the interactable itself.
So I decided I want to add a new function to all of my interactables, is_valid_target. By adding this new function to all of my interactables I can have them locally determine if they should be interactable instead of trying to account for everything in my player character. At the moment the player character actually looks at specific public variables on each interactable. But not all of the variables are relevant, so I have to include placeholders in some places. This new change should streamline things so much.
What I Did
I started off by adding a placeholder function that just returns true to all three of the relevant scripts. After that I took the code from my player character and broke it out into another place to pick it apart. I had to figure out the specifics of what this thing was checking. I felt like this was going to be pretty easy but it ended up being even easier than I thought! For the most part I just copied the if statement from my player character and moved it into my other scripts.
Of course, nothing ever goes quite the way it is planned. The change to my NPC and interactable template was no issue, but there's something about the induction terminal that's just not working right. In the end it was my own fault, and it took way too long to realize the issue. I used the initial logic I had laid out, but didn't realize it was reversed from what I was doing. So it was evaluating everything correctly, but returning the opposite of what I wanted.
After a quick fix in the logic I got the results I wanted. Now my player's targeting logic is separated into appropriate buckets. I don't have to expose as much data from the interactable, and I don't have to extend my player character's targeting logic to account for every possible circumstance. This is an important change.
What's Next
I hope tomorrow I can finally dive into the update to my savegame manager. I keep putting it off because I'm worried about the complexity involved. I'm sure it won't be as bad as I expect. I know I have a tendency to build things up in my mind as these huge, insurmountable challenges. But in the end I just break them down into their component parts and push through!
Xenodochium
The future is what you make of it!
Status | In development |
Author | Munchmo |
Genre | Role Playing |
Tags | 2D, Cozy, Godot, Indie, Life Simulation, Pixel Art, Sci-fi, Singleplayer |
Languages | English |
More posts
- Playerstats Manager: Skinning the Player1 day ago
- City: Building States2 days ago
- Saving: World Object States3 days ago
- Quests: Objectives and Triggers4 days ago
- Getter Functions: A New Approach5 days ago
- Lazy Dev: Day Off?7 days ago
- Dialogue System: Quests8 days ago
- Displaying: Quest Objectives9 days ago
- Induction Terminal: Raycast Refit10 days ago
Leave a comment
Log in with itch.io to leave a comment.