How to Program in Unity: State Machines Explained

How to Program in Unity: State Machines Explained

250.715 Lượt nghe
How to Program in Unity: State Machines Explained
Learn the fundamentals of programming State Machines in Unity with this new video break down! This tutorial explains important concepts of the State Pattern, and how to use State Machines when programming! Today we will walk through an example project to showcase the benefits of using state, the state pattern and state machines in Unity! This is the first episode in a new series of videos on this channel: Programming for Production. In this series, we'll take relatively complex software development topics and try to break them down in easy-to-understand way. Let's take our programming skills to the next level! SUPPORT THE CHANNEL: 💛 https://www.patreon.com/iHeartGameDev iHeartGameDev Merch: 💛 https://www.iheartgamedev.com WANT MORE? Interested in learning more about animating characters in Unity? Check out my growing series of tutorials: ✅ https://youtube.com/playlist?list=PLwyUzJb_FNeTQwyGujWRLqnfKpV-cj-eO ✦ Like the vid? Please consider Subscribing! https://bit.ly/2YdIb6j ✦ Missed out on the last episode? https://youtu.be/bXNFxQpp2qk SOCIAL: ✦ Discord https://discord.gg/2AxUvsa ✦ Twitter https://twitter.com/iHeartGameDev LINKS FROM THE VIDEO: 🤖 Download Jammo for YOUR game: https://assetstore.unity.com/packages/3d/characters/jammo-character-mix-and-jam-158456 ⭐ And Check Out @mixandjam ! https://youtube.com/MixAndJam GEAR: Lumix G7 Camera: https://amzn.to/3Kks1gZ Epomaker GK68 Keyboard: https://amzn.to/3Ke87EB Samson C01U Pro Mic: https://amzn.to/33kDdtG LG 27" Monitor: https://amzn.to/3qAHFwS Lepow 15.6" Portable Monitor: https://amzn.to/3287OtL Logitech G604 Mouse: https://amzn.to/3A6jNV4 Audio-Technica ATH-M50X Headphones: https://amzn.to/3tBaeMT X-Pen Artist 15.6 Pro Drawing Tablet: https://amzn.to/3FE5HLI Apple 15in MacBook Pro Laptop: https://amzn.to/3AbKdFc ►TIMESTAMPS: Intro: 0:00 The Problem: 0:40 What is State: 0:57 Anything Can Have State: 1:42 What does State do: 2:04 What is the State Pattern: 2:38 Bad-Implementation Apple Pseudocode: 3:08 Making it more complex: 5:04 Why This is bad: 5:55 How do we use the state pattern to fix this: 6:51 Finite State Machine Explained: 7:18 State Machine Implementation Explained: 8:25 Implementation Example Begins: 9:48 Creating Current State and Instances: 11:17 Defining Methods: 11:50 Setting Current State and using State Methods: 13:20 Running Update within State: 14:15 Switching States: 14:59 OnCollisionEnter: 16:44 Finishing the Example State Machine: 17:03 Finished Product and Benefits: 17:27