I Made a Desktop Pet in Godot

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
a little over a week ago I set out to make the most useful and practical type of application a desktop pet I feel like outside of a few examples I haven't really seen many of these since the olden days of computers I remember them being fun and weird and janky so I wanted to try to replicate that since I've been trying to learn gdau I decided to use it again for this project which may have actually made certain things a lot more difficult than they needed to be but I learned a lot I have a lot to share so this is my journey making a desktop pet in gdo so I started in the first day by trying to make some pixel art and animations for a potential pet I would totally change these up many times throughout this journey but it gave you something to start with then I made a gdau project and added the Sprite to the scene and then started trying to figure out how to actually make it render with a transparent background so you could just see it on your desktop transparent my initial idea for how to impl the pet was to make the gdau window full screen and transparent and have your pet moving around that transparent window and then setting the mouse pass through the true so that you could click through it but that just wasn't working and I'm still honestly not sure why it doesn't work it seemed like just some sort of bug with gdau and maybe the operating system I was trying to figure out another approach since just setting Mouse pass through didn't seem to be working and I found that the window has another property called Mouse pass through polygon which allows you to set a polygon region of the screen that except Mouse clicks and then everything outside of that will pass the mouse click through so in theory I could just set the mouse pass through polygon to a polygon that encompasses just my my character and then the rest of the screen will pass through Mouse clicks but I just couldn't get that working I didn't know what was going wrong and I was getting a bit tired so I gave up and decided to come back the next day the next day I came back and I decided that I wasn't satisfied with my pet pixel art so I decided to try to make some more I came up with this kind of Buddy bear design and this would change many more times still over the course of this project then I went back to trying to figure out why setting Mouse pass through polygon wasn't working as I wanted and and it took me a while there were some weird visual issues and I had to tweak some window settings and some code but eventually I got it working and I got my pet showing up transparent over the windows pets obviously can't just be stationary so I then decided I wanted to make the pet move across the window and to do that I had to make sure to update the mouse p through polygon as the pet moved across the screen based on the sprite's location I then made the pet follow your mouse movements and I noticed some weird visual glitches at this point kind of around the edges of the mouse pass through polygon and I wasn't entirely sure why those were happening I'm still not entirely sure I don't know what that box is from the character I guess switching to physics process fixes that weird issue I then switched up the art again now for a third time to a fox I found on itch.io not something I made myself but that will change again and I thought it was looking pretty cute it was a bit hard though to edit my code at this point because the pet kept constantly walking over it and then made it so that the pet plays back in idle animation once it gets to its destination which at this point was where your mouse was at this point I started thinking about how I could expand upon this idea and let the pet interact with maybe other pets or other objects in the world on the desktop and that's where this whole thing kind of fell apart I realized that with my current approach of this full screen transparent window I actually just couldn't add more objects or more pets to this window because when you set Mouse pass through polygon it actually just doesn't render anything outside of the polygon at least on Windows and that would be a problem because nothing else would show up other than the pet and you can only have one Mouse pass through polygon set per window so I couldn't just have two one for the pet and one for a home I was doing some research and I found a really interesting article that would end up helping me a lot that described the technique for making multiple windows share the same world in gido basically little views into the same world and I didn't understand at all how to impl this when I first found this article but it would come in handy a little bit so because at the time I wasn't totally understanding that article I decided to try to do my full screen transparent window with another small window on top and I actually did get that approach working I had both pets showing up on the screen but it was really tricky to handle Mouse events and get them to go to the right window to the right pet I was trying to forward relevant input events from one window to another depending on where they clicked but it was just getting really tricky at this point I wasn't loving how this project was feeling it felt very hacky and like I was fighting Gau and the operating system and that Mouse pass through didn't really feel like it was consistently working so I was realizing what I probably already knew earlier in the day that I really needed to just sit down and rethink my whole approach to this project so I decided to take a break and come back the next day the next day I came back and I decided to just completely scrap the project and start over from scratch let's just start over I spent some more time looking through that multiple windows article and I understood the approach a bit better so I decided I wanted to try to implement something based on that to just avoid Mouse pass through issues in general I think I'm going to try making the main window just as small as the character and then I will maybe try spawning other windows that show the same world as the characters in that way I think I won't have to worry about Mouse plaster as much because that seems kind of buggy I spent a while longer here looking at the tutorial article and the code and trying to figure out how to actually get this working in my game started up by placing my pet in some potion Sprites I had made in my main scene and my idea was that I would show these potion Sprites in these World windows then I made a world window class that extended the base C window node the initial script for this class ended up actually being pretty simple all I had to do was set the world 2D of the window to match the main Windows World 2D once the main window had fully loaded and then in process I would update the position of the attached camera to match the position of the window on the screen so that you would see the correct underlying World depending on where the window was I did run into some bugs here had to do some troubleshooting why are they different which one's the real one but I eventually got it working where I could just move that window around my screen and see Peaks into my underlying world the same world as the the pet is in okay I guess this is working question mark I then added some code to spawn World windows for each object on the screen so that they would wrap where they were so you could see each potion without having to move a window around and I would improve this later but it was working for now this day started out yet again by trying to make more pixel art I had decided at this point that I wanted my pet to be a bird because I thought it would be fun for it to be able to fly around your desktop maybe land on top of Windows things like that so I need to make some more art this was difficult for me I tried to make it Dove it ended up maybe more like a seagull so I'm just calling it a bird I spent a lot of time here trying to animate it in different ways I made an idle animation where it squishes and gets stretchy and I made a flying animation which I later improved and I also tried to make a walking animation but it didn't look very good and I didn't end up using it anyway that tail is pretty crazy F animation is not that bad honestly I was still having issues at this point trying to figure out how user input was working CU I wanted the user to be able to click on the bird and click on a different object in the world and know where they click so I could have different things happened but that wasn't really working as I expected it to sometimes when I clicked on the potion it wouldn't get the click event sometimes it would depending on what was in focus and this was kind of a mess and I was just actually really confused about how things were working but I came back to this the next day again I started this day with some pixel art I tried to improve the bird flying animation by adding some blur frames when it flaps its wings and I think it looks better so I stuck with that looks not bad right kind of like it I then made the bird follow the the mous on the screen again as I had in my very initial demo next I had decided that I wanted to add a home that the bird could return to when you click on it to get the bird out of your way on the screen but to do that I had to figure out what was going wrong with my click events both the bird and other objects in the world had area 2DS on them which should have allowed me to get input event signals when the user clicked on them I wasn't sure to fix this though I started brainstorming ideas but nothing was really working I eventually realized that what I needed to do was query the physics engine for the world directly with the location of my current Mouse click and then if the collider or its parent had a handle click method I could then just call that method kind of weird but I think it's working I can now tell if things are getting clicked I cleaned up the code and then switch to having the world Windows push back the events to the main window to handle in one place so that regardless of which window is focused everything would be handled the same so now using this functionality I wanted to add that pet home that the pet would return to whenever you clicked on it it just more pixel art and it decided on a simple bird perch I added it to the game World in a world window and baited so that when you click on it the pet flies to it and then just sits on it that's kind of cool and then I made sure the window movement code was working by having the bird perch move across the screen I had an issue here though where the bird perch was getting cut off a bit because the world window wasn't sizing exactly correctly even though I was giving it the correct sizing this was a weird issue to figure out it took me a lot of time and it ended up just being that if I toggled borderless off and then back on again in the code then it would work fine and be sized correctly so not the best thing to spend a lot of time on but I fixed it oh okay this has to be a g bug I assume now I wanted to add the ability to actually move the bird perch around the screen where you wanted it to position your pet once that was all working I made it so that when you click on the home and the pet fles to the home that when you drag around the home with pet on it it just stays put on it so you can place it wherever you want and I also fixed some related bugs that were happening when you like grabbed the home out from under the pet very quickly and things like that then I wanted to make the pet love you so I made a quick pixel art heart and then use that as a base for a particle system in Geto I played around with the settings for this for a while to get the effect I wanted and then I made it playback when you clicked on the bird initially I had a problem here because the window was the same size as the bird which meant that the hearts would just get cut off oh now the window's too small I need to fix this so I could just expand the window make it bigger from the start but that would make a bigger of the screen not clickable which I kind of wanted to avoid so I thought was that when you click on the bird the window would just temporarily expand and then shrink back down after the particles are done playing now this did work but I really only wanted the window to expand upwards because that's where the particles were going and I didn't want to expand the unclickable area where it wasn't necessary but that was actually really a struggle for me because I'm really bad at this sort of thing and figuring out this sort of world math kind of things so this took me a lot longer than I would have liked to figure out might have just figured out the formula for this after doing some calculations I'm really mad at this sort of math let's see if it works all right I think it's doing what I want now I can see all the heart particles and it's not you know covering up too much of the screen outside of where the particles are now this day I got some really fun things working I first added a rainbow Shader effect for some reason on the bird and I just thought it was fun I don't know what I'm using this for but it's fun now from the beginning of this project I had the idea that I wanted the pet to be able to interact with open windows on desktop in some form maybe walk around the tops of them and since I switched the pet to being a bird I thought it would be fun if the pet could fly to open Windows and just land on them and sit on the tops of them I need that to get the positions of different windows on the user screens I would need to access lower level native OS apis and I decided to just focus on Windows because I thought it' be too hard to do both Windows and Mac I did some research and learned that I could use C with pinoke to access Windows native apis pretty easily and that was great because gdo supports T and and GD script so it would just work I did though have to download a different version of gdau to get C scripts working my thought was that since my entire game was a GD script I could just write one C script that would do the communication with the Windows operating system get the window positions and then pass it back to my GD script for my pet to use for its position I didn't have any experience with C or Windows API so I asked AI for a little bit of help to get the boiler plate started and it actually wasn't that difficult see what happens I guess oh that actually worked it's a lot of Windows though so this isn't too bad really just from the coding from chat gbt I can use this user 32 dll to access Windows API through C and I can get window information the problem is that it's hard to know which windows are actually visible on the screen so I think I need to dig a little bit more into the windows API now so I decided here instead of spending a ton of time figuring out whether each window is really visible on screen or not that I would just use a different API get foreground window which would return the focused foreground window that the user is interacting with because that window would definitely be visible and then just allow the bird to only fly to that window so that was surprisingly easy that working I just had my C script pull the foreground window information in its process function and then in my GD script I was able to read from that c script and get the foreground window information that's cool that wasn't that hard to get them communicating then all I had to do was check if the active forr window was actually part of my gdau app or not because I didn't want the bird or the perch window to count and then I had to check if the window was perable meaning that the bird could actually fit so it wasn't too high up on the screen or too far left okay that seems reasonable I think now we make it fly to the top of the window in the center and then I just wrote some code to have the bird fly to the middle of the parable foreground window and it just worked it was really cool look at it go I love this I took a 3-day break from working on the the project but then I came back and I was intent on polishing it up and finishing it I spent some time just improving the logic around how the bird decides to fly to the mouse to its home or to a window this was actually surprisingly tricky because the way I had coated the bird was not the best pretty messy and just a ton of different booleans that track it State and if I were making this a bigger project and continuing to work on it I would definitely need to refactor how the bird code was working and probably mov it into some sort of State machine but since this was my last day working I decided to just grind it out and figure it out with what I had this code is a bit of a mess but I think I'm going to leave it for now because I don't feel like fixing it I then added a pop-up menu when you right click on the bird with some settings including whether the bird should fly to Windows and whether it should follow your mouse and also an option to quit I also made it so the rainbow Shader would only show up on double click and then fade away over time and then decided the bird should make a happy sound when you double click on it so I went looking for some bird sounds and I experimented with a few different ones before finding one I liked all right I'm pretty happy with this it's fun it doesn't me me do everything I had Ambitions for but I think it's good enough for this video after all these days of work though I'm still not sure what type of bird this is so I might just call it Bird yeah I think we're done and then I decided I was done there definitely a lot more things I could add but I decided I was happy with what I have for now and maybe I'll come back in the future and add more so this is the final pet and it's up next now on itch.io which I'll have Linked In the description if you'd like to try it out as well I'm honestly not totally sure how well this will run on systems that are different than mine because it seems like the transparency stuff is all over the place and not super well supported but let me know if it works for you overall this was a really fun project and I'm quite happy with the final result but I did spend quite a bit longer on it than I would have liked and that's because I got stuck on a few different issues and I also didn't really have a strict plan from the beginning of what I actually wanted to implement so I think in the future I will try to have a better plan going into projects I also do think this project could have been easier in some ways had I not used gdau because a lot of my time is spent fighting gdau systems for Windows and transparency and trying to figure out what was going wrong with different parts of gdau itself and I'm not saying these things are definitely gd's fault but this project may have been a bit easier using something a bit lower level I think for our next project though I'll try to pick something a bit less weird that has way lower potential for OS related issues so please try out the desktop bird and let me know what you think and also let me know what project you'd like to see me tackle the future thank you all so much for watching and I'll see you in the next video
Info
Channel: RachelfTech
Views: 97,882
Rating: undefined out of 5
Keywords: godot, desktop pet, desktop bird, game development, game dev
Id: x8BO9C6YtlE
Channel Id: undefined
Length: 16min 2sec (962 seconds)
Published: Mon Jun 03 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.