How To Make Flight Simulator In 5 Steps | Beginner Game Tutorial In Unity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome to the fourth episode of one minute games let's do some flying today like and subscribe and stick to the end for the bonus project [Music] as before let's use a cube of dimension 20 by 20. airplane first needs a body duplicate it and stretch it to also add the wing and a tail add a final copy with a glass collar for a cabin where the pallet sits rotating propeller can be visualized with the transparent cylinder after creating a script file we are ready to code let's start with a simple forward movement increase position in the forward direction multiplied by fly speed at the end multiply by the delta time to compensate for frame drops we can see the airplane move forward in any direction it is looking at let's control the direction by the left and right arrow keyboard keys airplanes can rotate in three dimensions yaw pitch and roll which corresponds to the x y and z axis in unity first let's get the inputs from the keyboard called horizontal meaning left and right we can create a yaw variable and increase or decrease it with either positive or negative input value multiplying with the amount variable we can control the speed of turning to steer left and right we need to rotate around the r axis or up vector steering should now work as expected next we want to go up and down we can do that by rotating around the pitch horizontal or x axis for this we can use up and down arrow keys each angle is between 0 and 20 degrees depending on if the key is pressed or not at the end multiply it by the sign of the input to get an up or down angle add rotation around the pitch axis for the right vector multiplied by the pitch angle we can now move like a real airplane left right and up and down but we can also add roll rotation for additional realism the last is the rotation around the roll forward or z-axis roll angle is calculated in the same way as pitch but using horizontal input also invert the design add rotation around the roll axis or forward vector multiplied by the roll angle we now have a finished flying movement of an airplane moving sideways going up and down and rolling convincingly we can see abrupt changes if quickly pressing the opposite key like left and right let's fix it in the last step in the project settings we can find the input manager here are the settings for the inputs we call in the code if we uncheck the snap option here the abrupt changes are gone the last key press won't overwrite the value but it will slowly transition to it here we can also change this transition speed by sensitivity and gravity options good job we're done flying is not that much harder than driving a car in a virtual world at least for more practice you can add gates to pass through and count score targets on the floor and drop packets on them or spawn particles when wings are touching the water combine the flying movement with the snake from the first episode and you can make this magnificent chinese dragon [Music] you can also support me on patreon where you can find all of the projects like and subscribe to get more videos thank you and see you next time [Music]
Info
Channel: One Minute Games
Views: 26,683
Rating: undefined out of 5
Keywords: Flight Event
Id: wq5YYldv1gw
Channel Id: undefined
Length: 4min 27sec (267 seconds)
Published: Fri Jan 28 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.