What Breaks When Porting to Godot 4 / Part I: Character and Camera Controllers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay um this has been an interesting week i finally gave godot four um a try i've been meaning to do this for months but honestly i've been scared uh of the amount of rework uh so instead i just procrastinated um and i kept explaining to myself that it's probably better to just wait for a more stable version or maybe there's a converter that will port everything over for me you know things like that but now having spent a few evenings trying to recreate my project in group 4 i actually think i should have started it way earlier because while the engine is not even close to stable the amount of difference between three and four is way more than i had anticipated it's not it's not just simple you know tweaks to the code the api has a different approach to some of the critical nodes uh the good thing is it only hurts for the first couple of days and once you're through the basic differences uh you're starting to slowly make progress again and enjoy it and it's kind of like learning a new engine in a sense at least for me because i've not been following gdelfor's development too closely so most of it is new to me anyway um this is where i left off in godot 3.4 and my plan for the next couple of episodes will be to recreate this in godot 4. so in this video i'll tell you about the key things i had to redo to get my player controller and camera systems to work with the new api inside of godot 4. as for my approach i decided to start a completely new project in godot 4 and move my resources piece by piece into this project which gives me a lot greater control of what's breaking initially i wanted to just open the 3.4 project in gado4 and address the errors but that turned out to not be feasible i couldn't even open the project in the editor to be honest with you the engine would just crash while opening so i would strip off the pieces which i thought might be problematic and after like a day of doing that the editor would finally not crash but instead it would give me uh literally thousands of errors which for the most part were meaningless to me so i thought i'd just start from scratch and uh and learn the engine in this way and clean up the project along the way as well so a win-win situation and that's what i did so here are the main differences i had to address to get the controller and camera to work in godot 4. the first thing you'll notice is that there's no kinematic body node anymore there's a character body 3d instead and it has a property called motion velocity and you have to use your direction and speed as the value for this property now so previously you would pass your direction vector multiplied by speed as parameters into move and slide in godot 4 move and slide doesn't take parameters you just call it in your physics process and it will use whatever value you put into the motion velocity property gltf skeleton and animations seem to be importing correctly except the importer looks a little different and a gltf import doesn't open as a scene it opens in a whole separate window that looks like this and it has some extra import options like you can define the type of looping or extract animation files meshes materials but if you want to use this import as a scene resource you have to instance it first so just drag it onto a new 3d scene the animation player works just fine what didn't work for me is animation tree grow 4 doesn't open godot 3's animation trees they show up as invalid or corrupt at least they did for me so what i did instead is saved the tree root property as a resource and i created a new animation tree node in inside of godot 4 and loaded up the uh that tree root and it worked just fine next up rigid bodies my weapons are all rigid bodies in 3.4 they would just be sleeping and i would wake them up if they were going to be dropped like when you're swapping weapons i've not done weapon swapping yet in in godot 4 but i did notice that the gun was getting offset from my grip when i was moving even though it was sleeping i don't exactly know what has changed but there's this new property for rigid bodies which by the way are now called rigid dynamic body 3d and and this property is called freeze and when it's on it literally makes your rigid body behave like a static body so i turned that on and it worked so i moved on next intersect ray i use a lot of ray casting from the mouse into the world that is how you know where your bullet target should be in a top-down shooter previously i used this code so i passed the ray parameters and collision mask into the intersect ray function in contou4 intersect ray only accepts one parameter but you still need to define your array points and collision mask at minimum and honestly this one had me scratching my head for a bit until i found this class physics ray query parameters 3d it has properties for from and 2 and collision mask and some more so just feed this with the values that you want and use it as the parameter for intersect ray also if you want to get world you have to say get world 3d because get world doesn't exist anymore next up we have tweens and tweens have changed drastically in godot 4 they're not even nodes anymore they're more like data types you create one by create node simply just like that and then you add methods to it there's a whole set of methods that a tween can take the basic one is the property tweener so just type between property and pass in the properties that you want to tween you don't even have to set each type or transition type anymore it will just use the default ones if you don't but if you do want to specify those then you have these methods available set trans and set ease oh and your tween will just play you don't have to call start and you can stack multiple tweens one after the other in your script and they will just play one after the other and if you want them to play in parallel set parallel to true on the next note down in your script and it will play simultaneously with the previous one uh tweens are a big shift in godot for uh they've gotten extremely powerful now there's a great tutorial explaining for tween class in full i'm gonna link it now and i yeah i suggest you go watch that and none of my set us top level calls would work again i didn't know why it turns out that they added a space between top and level it annoyed the hell out of me i was like why would you do this there's no value in this tiny change it just breaks a lot of code the other thing which will drive you a little bit nuts is annotations you have to add an ad in front of them in a majority of cases this is not a big deal because you would just literally add an ad in front of your unreadies and exports or even maybe use a converter to do that for you there's a pr on github that does auto conversion but it gets a little more tricky when you want to specify ranges and enums for your export variables the documentation has some gaps on this so here are a few examples of how we can do it um in keto 4. yield has been replaced with a weight i'm only using yield in two ways in the project one is to create a timer with a timeout signal and the other one is to wait until a tween has completed so here's how you can use a weight in those two cases next thing that got me a little frustrated is lerp i do use lerp to interpolate a vector3 in a few places and the way i did this in 3.4 is for example i would say vector 3 equals lerp and then i would pass in the parameters from 2 and weight into the parentheses it didn't work for me in 4 for some reason i don't really know why because i wasn't getting any errors from the engine turns out there's a there's been a subtle but code breaking change now you have to attach lerp to the vector that you want to interpolate and just pass in the target vector and weight like this so these were the main things that got me frustrated uh in retrospect they seem fairly straightforward but i did sweat over them some of them for some time and this is not the end of it this is just the core mechanics i still have to rebuild gun swapping reloading and a few others to get my player fully ported i will be recreating the full project in godot 4 and i'm planning to do this incrementally so do consider subscribing to this channel if you're planning to port your project to 204 and who knows maybe my experiences will help you alleviate your transition my next increment is going to be focused on getting the enemy animations and movement to work in 204 and something's telling me this there's going to be challenges on that because it seems that the navigation node and the navigation mesh instance which you would normally use as a child of navigation have been merged into a navigation region node and i don't yet know what that means but i remember getting navigation to work with tiles in 3.4 was a truly traumatic experience so honestly i don't even know what to expect in godot 4. so stay tuned if you're interested hope this has been of some help leave a like if it was and i'll see you all the next episode happy holidays [Music] [Music] [Music] you
Info
Channel: devmar
Views: 985
Rating: undefined out of 5
Keywords: Godot, indie game dev, gdscript, godot game development, 3d game godot, godot 3rd person shooter, godot shooter, godot shooting game, godot 3rd person controller, third person shooter godot, godot engine, game development, unity, godot optimization, top-down games pc, top-down shooter, godot multimesh, godot bullets, godot projectiles, godot 4, godot 4 port, migrate to godot 4, godot 4 features, godot 4 third person controller, godot 4 tut, godot 4 tutorial
Id: Q_miIugqx3Q
Channel Id: undefined
Length: 9min 38sec (578 seconds)
Published: Sun Dec 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.