• Projects
  • Project Regina - 3D 3rd person demo (Godot 4)

This is looking really cool. Reminds me of The Sims.

a month later

I have done the Inventory and Shop. It is based off this tutorial. I just added more functions / modified it to my likings.


This is the Player Inventory. It has 4 tabs, 1 for each item category (Clothings, Accessories, Items, Food). Right now they are all empty. The right panel to show item Infomation and buttons.


You walk to the shop and the Shop Inventory is activated. You then buy items and it will be placed in its category tab (in the Player Inventory). I also use ScrollContainer, there are empty spaces to put item descriptions and quantity.


For Clothings Tab, there are 2 places where you can put item on the player, Body and Hip. They are just node3D positioned in player's scene. Then when press button it checks the name of item in that category then add_child it.

I also got the Tick system when one of the Body/Hip item is being used.
(by checking var is_used = true then make the sprite2D tick visible)


I got a swimsuit item which is just swaps player's texture and play shapedkey to expand the hip back to normal proportion. (I originally shrank the hip so it won't see through clothes that much)


You can unuse items and discard them


For Accessories Tab is pretty much the same. I use boneattachment for head bone and wrist bone. I add jiggle to the Bunny ears.


For Items Tab is just a pop up to show more details. Maybe use for clue or map or use key for doors..etc.


For Food Tab, each Item can be stacked and used up. In this demo I use it to change variables, for example, Chocolate bar will decrease Health, Apple with increase it, and Cake will increase coins.

This inventory code is kind of a mess, many duplicated codes, and totally unoptimized. I don't think it can/should be used in real game. There are also still room for improvement like sorting items. Overall though I'm pretty happy that I could make this Inventory work.

Next I will try doing the scene switches and to carry those player's equipped items over. Then the save/load function.

Well, it's almost an alternative to the The Sims. There's just a little bit of tweaking left to do. ๐Ÿ˜น

    Tomcat

    Far from it LOL. There are still so many things for me to learn in order to make any complete game.

    18 days later

    Not much new to show visually but I've managed to do the Scene Switching and Saving/Loading game.


    Methods:
    Scene Switching : using change_scene_to_file(). I have a player_load function that checks any inventory items being used == true then add_child() them.

    *I have red error regarding the body's materials. There is an github issue on it. I'm not sure it is fixed in the latest version. (I'm at version 4.0.1 rc2) https://github.com/godotengine/godot/issues/67144


    Saving/Loading game : using JSON (tutorial from document). Save all the inventories + player's info to JSON then load it all back, then player_load function.

    *There is a bug when saving player's health. I have to close and reopen the Menu then press save button in order the save the player's health correctly. The problem is that I put save function in Inventory Menu and while Menu is on, the mainscene process is disabled. I guess for a real game I'd need the put the save button somewhere else.

    Next I will try to add water with shader (pool, beach) and have character interact with it.

    As always โ€” very interesting and extremely informative! There's a lot here that I've been thinking about how to implement. It was a great pleasure to look at it. I wanted to try to implement saving via JSON too.

    With your generous permission, I'll steal the ideas into my project. ๐Ÿ˜Š

      Tomcat

      No need to ask for my permission ๐Ÿ˜ƒ . Those are already available on internet, youtube..etc (just search godot 4 scene switching/ saving/loading tutorials). But if you don't have access to youtube then don't worry, most of those tutorials are using official doc methods anyway.

      Change scene by change_scene_to_file() : https://docs.godotengine.org/en/stable/tutorials/scripting/scene_tree.html#changing-current-scene

      Change scene by add_child() : https://docs.godotengine.org/en/stable/tutorials/scripting/change_scenes_manually.html

      Saving game by JSON: https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html

      Saving game using Resource : *Haven't tried yet but supposedly is easier than using JSON

      It's not hard but I guess the most "thinking" part of this procedure is decide which infos you want to send over (player's health, location, items..etc), where would you get those infos on your scripts, and how would you put those back to your player once you load it from JSON file (Might need to do some values conversion too). It will depend on how your setup your trees and scripts.

      You can check out my profile>discussions. I've been asking about it in recent weeks, there might be some useful stuffs for your project.

        Gowydot It's not hard but I guess the most "thinking" part of this procedure is decide which infos you want to send over

        It's a Sims-like game. So the amount of information saved will be quite large. But not right away. I will be making a small game to start with. I suppose there will be a lot of prototyping and investigating different approaches to implementing various features.

          5 days later

          Tomcat
          I'd say just go for it. You'd find that you need to make a lot of adjustments while you put it all together.

          In a mean time, this pops up on my youtube and I finally understand what they all means ๐Ÿ˜„.

            Gowydot In a mean time, this pops up on my youtube and I finally understand what they all means

            That's rightโ€ฆ I've run into this before and I guess I understand it wellโ€ฆ but I have two chits: I am not time-bound and there are no grants to account for.

            Just a footprint test, not really accurate but I'm ok with how it turns out. I have a raycast shooting down from body then place 2 foot sprite3Ds alternately. The sprites rotate according to the body's rotation.

            Wow! Well, such graphics would already be quite suitable for a Sims-like game. A small glitch when the camera is on the edge of the water, but I guess this is a common problem. By the way, what kind of shader?

            Very cool! ๐Ÿ‘๏ธ

              Thanks all.

              Tomcat
              For that gif I used -

              Although I'd probably end up just using animated textures instead 'cause my laptop gets too hot with shader LOL.

              Also, you couldn't see it on the gif but there are artifacts around the character when on top of the water shader, especially around the head area. I don't know if it's because the hair area has alpha texture or something else.
              *just tested and confirm it is the alpha material in front of shader issue, how to fix this?

              A small glitch when the camera is on the edge of the water

              Yea I've been researching on how to do half underwater camera effects. As I understand Godot would need a thing called stencil buffer which Godot doesn't have currently (correct me if I'm wrong), or it would requires a lot of shader/viewport/another camera trickery which kinda out of my league.

                Gowydot *just tested and confirm it is the alpha material in front of shader issue, how to fix this?

                I have observed a similar problem. As far as I understand, the solution is all sorts of masking and hiding it. The solution is, of course, palliative, but there doesn't seem to be any other solution yet. It could probably be a very good pull request. Along with a stencil buffer.

                  Seeing all this makes me so excited to get back in 3D. The last two months has been nothing but string processes, arrays and pseudo-filesystems. For those that know, Black Daemon is still in development :-). The underlying code is vastly over-engineered, but it's wrinkling my brain tenfold.

                    Tomcat
                    I read there is a stencil buffer pull request and possibly available in 4.1 or later.

                    packrat
                    Yea I'm glad I got over the Inventory and Scene switching/saving parts. Now to the fun part for me. (Visually fun, at least)

                    16 days later

                    Let's go for a swim!
                    There aren't many tutorials for swim in 3D. I basically found one so I use his implementation, which I also need to modify my State Machine to be able to work with his method.


                    She can walk/run/jump into the water until it reaches her chest and she will float on the surface. She can move around slowly on the surface or swim breastroke style by pushing a button.

                    I have an area3D at her chest to detect the difference between water surface and her. I use that number to indicate where she is from water surface and what to do. For example when she is closed to the surface, I slowly float her up. If she's far down she will be in underwater state and float in place..etc.
                    The downside is I can't go anywhere else below the water surface, Maybe need a check somewhere outside of water area to deactivate her swimming state.

                    The tutorial also uses her velocity to decide what to do as well. For example if her velocity.y is almost zero then go to floating state..etc.


                    She can dive to underwater. It's kinda tricky to get the animation to match the timing before changing state. There is a way to code it in the tutorial but I didn't add to it yet. Maybe will come back to it later.


                    She can slowly move or swim on / under / up to the surface. There is a little bug for swim up, if you let go of the button she will stay still but won't change her legs kicking state)


                    Swimming back to the beach and going to the pool


                    The Swimming pool has a springboard. Once gets on she can jump very high. It's just an Area3D at the tip and increase jump velocity. The board have bounce animation but it finishes too quickly to see.


                    Just had to add jump out of pool temporary because I forgot to add a pool ladder.

                    Swimming has a lot of room to improve but I'm very happy to make it work (always been a goal of mine). I can say that my main objectives here are pretty much completed. I feel I've learned so much game making with this project. (It's not easy as the project gets bigger, your codes get messier). I will put a break on this but will come back to this occasionally to add other interaction stuffs, if I have free time.

                    I now plan to complete small, actual game project and try to test publish it. (Maybe just a sidescroller in 3D with like 4-5 levels) Also plan to learn to make a 3d fighting game. See you next time!