Swipe Controls with ChatGPT & Player Jumping

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in today's episode we are going to add the jumping ability to our 3D character we are going to download an animation from mixamo.com then we are going to ask share GPT to write this sketch that will check for the swipe controls and without any further Ado let's Dive Right In first of all we need to download the animation from mixamo.com I've already selected the same character that I'm using and under the animations tab let's search for running jump then we can pick up any of these animations and we are going to use root motion which means that the animation will drive the character we are not going to write any line of code let's download it using the download button make sure to select fpx for Unity and we don't need the scan then let's hit download next we have to import it in our project by dragging the jump animation and let's put it under the player folder before we can use it we have to change some settings under reg make sure to change the animation type from generic to humanoid then let's hit apply when we have applied the Running Animation Unity created this animator controller that we can open up by double clicking on it and here we have the animator window by default the player is running so to use our jump animation we have to drag it under the animator window then we need to make a transition from running to jump that we can control whenever we make an up swipe we have to right click then make transition and select the jump animation and the way we transition from one animation to another is by creating a condition if you press this plus button we have this message parameter does not exist in controller in fact we have to create a parameter to control it under the parameters tab let's add a new one we have a float normally we use it to change the speed of the player in my case I'm going to use a trigger so that we can switch to the jump animation and let's call it jump then we can select the transition again and from the inspector will be able to select this trigger so that we can activate this transition but we need to get back to the Running Animation as soon as we finish the jump animation we need to make Transition from the jump animation to the Running Animation and in this case you don't have to set a condition by default the player will transition back to running as soon as this animation is finished and that's what we want at this point we haven't talked about the player inputs we can activate this trigger from the animator window to do that we need to drag it under this area so that we can see our game View by default the player is running and each time we activate this trigger the player jumps but we have few issues the player is a little bit moving to the left side and the way we fix that is by selecting the jump animation and under animation here we have something that is called bake into pose if you select the first option we are going to enable root transform rotation bake the same thing we have to fix the Y position and make sure that the best upon is set to original by default the player is running and if we set this trigger he jumps we can set again we're going to change it from the code later on to check whether we have an up swipe we activate this trigger but first of all I'm going to show you some parameters if you select the transition we have this option as exit time make sure to uncheck it so that we can immediately transition from the Running Animation to the jump animation and under settings we have some other parameters like the transition duration make sure to play around with this parameter to get the best results and let's give it another try and there you go the player jumps now we want to read the user inputs so that we can set this trigger whenever we have an up swipe and so on to make it easier for us I'm going to use this tool probably you have heard about it it's an AI model that you can ask it whatever you want I've already created a video on how to use this tool so let's ask it a question like HR GPT I'm making an endless Runner game using Unity so write me a c-sharp script to check for swipe controls and by pressing the enter button you will get the result that you want we have the c-sharp script which is called swipe controller now we can copy it using copy code and go back into Unity we have to right click create c-sharp script and we have to give it the same name swipe controller by double clicking on it we can open it up in Visual Studio code where let's use Ctrl a and Ctrl V to paste it under the update function which is called over and over again we have these lines of code like debug.log whenever we make a left swipe we will see this message left swipe detected to check if this script is working just fine I'm going to use Ctrl s to save it then we need to add it to our project I'm gonna drag it under the player and hit play then if we move the mouse to the right side we have right swipe detected the same thing for the left one it seems to be working just fine but I think they haven't added the up and down swipe detection we can get back to chat GPT and ask it to fix that GPT the up and down swiping doesn't work can you fix it and hit enter again and there you go we have this apologies then let's get back to the script and use Ctrl a control V and let's give it another try we have up swipe detected the same thing for down left and right so it is working finally we can set this trigger whenever we have an up swipe to do that we can access the animator component because we have the swipe controller attached to the same object that has the animator we can get back to the code and under up swipe detected we can use a built-in function which is called get component this takes in the name of the component that we want and it is the animator component then we add dot set trigger to set the trigger this function takes in this string which is the name in our case it is called jump and let's hit play again so I think that's all for this video I hope you like it now we can jump using these swipe controls in the next video we'll be able to move it left and right using the right and the left swiping so if you have any question or comment make sure to write it under the comment section down below and they will see you in the next one
Info
Channel: GDTitans
Views: 3,467
Rating: undefined out of 5
Keywords: GDTitans, endless runner game, unity, unity3d, temple run, subway surfers, endless, runner, running game, game, game development, game for android, infinite runner, player running, Unity Endless Game, unity android game, swipe input, swipe input unity, swipe controls, mobile swipe inputs, mobile, touch controls unity, touch controls, mobile swipe controls, chat gpt, unity tutorials, jump and gravity, jump with root motion, jumping in unity, jump, root motion, unity 2023, swipe
Id: fMvz7f7BdeQ
Channel Id: undefined
Length: 7min 6sec (426 seconds)
Published: Sun May 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.