Тёмный
No video :(

E07 - State Machine Introduction // Make An FPS in Godot 4 

StayAtHomeDev
Подписаться 40 тыс.
Просмотров 18 тыс.
50% 1

Опубликовано:

 

23 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 94   
@stayathomedev
@stayathomedev 9 месяцев назад
This is getting to be so much fun! Hope it's helpful for you guys 🔥 GET THE SOURCE FILES ►► www.patreon.com/StayAtHomeDev_ 👉🏼 FREE BASIC FPS SETUP SOURCE FILES ►► github.com/StayAtHomeDev-Git/FPS-Godot-Basic-Setup
@Legit_SuperFall
@Legit_SuperFall 2 месяца назад
I found a much better way to check if the player is moving get_real_velocity().length() This gets the actual velocity, not intended velocity. This works better because sometimes you want to move but you cant, like you're up against a wall or something
@Legit_SuperFall
@Legit_SuperFall 2 месяца назад
I just want to say to anyone that isn't sure if they want to implement this. Do it. If you're worried about time, It won't add almost any time to implement it if you do it early. It might take a bit if your code is getting confusing, but it will take you mush less time now than later when it's worse. And if you're wondering if it's really worth it, it is. It's much easier to implement new things and everything is much more organized. And if something breaks, it won't break everything else.
@nikolastanojevic6082
@nikolastanojevic6082 6 дней назад
I had a trouble with this part in bugged out version of Godot 4.1, in 4.3 it works as expected. Thank you for the tutorials.
@joker31freak
@joker31freak 9 месяцев назад
I was following your tutorial series up until the last video and decided a state machine was a great idea, so I implemented that last weekend :D Awesome to see your take on it and great tutorials so far!
@stayathomedev
@stayathomedev 9 месяцев назад
Thanks! Going to be working with states for a bit to flesh out the movement. Then we get into some more fun stuff ;)
@joker31freak
@joker31freak 9 месяцев назад
@@stayathomedev looking forward to it! Will you be extracting the movement code itself to the states?
@rechnight
@rechnight 9 месяцев назад
Just finished implementing a State Machine that works differently. States are children of the State Machine, then Actions and Transitions are children of States and Decision is child of Transitions. This way can split into reusable Actions and Decisions. And also swap StateMachines realtime for different phases
@iglobrothers645
@iglobrothers645 7 месяцев назад
Mind explaining a bit more in depth on how this works / what exactly you mean?
@rechnight
@rechnight 7 месяцев назад
@@iglobrothers645 Instead of having all the code of actions and transitions inside one state script, I split into State, Actions, Transitions and Decisions. State and Transition scripts never change, just drop them to the nodes and set the True and False states for the Transitions. Each transition should have only one decision which will return True or False. Each state can have any number of Actions, which I like to make as simple as possible for reusability.
@andguy
@andguy Месяц назад
Half way through, I'm loving the inclusion of some error handling! Another great video so far.
@stayathomedev
@stayathomedev Месяц назад
Glad to hear it!
@PsychonicJoe
@PsychonicJoe 9 месяцев назад
Another way to pass the player reference programmatically is to get a single reference for it in the state machine then pass it down as a property to each state when iterating through children. Nice tutorial!
@2dspaceadventuregame952
@2dspaceadventuregame952 9 месяцев назад
I don’t get why your channel isnt at 100k yet. You make amazing content! ❤
@stayathomedev
@stayathomedev 9 месяцев назад
Wow! Thanks!
@nestorpiedraquesada2954
@nestorpiedraquesada2954 9 месяцев назад
This is amazing! I just fiunished my implementation for episode 6, now time to get my hands on StateMachines!! Thank you so much for this content!
@stayathomedev
@stayathomedev 9 месяцев назад
Awesome! State Machines rock!
@nestorpiedraquesada2954
@nestorpiedraquesada2954 9 месяцев назад
@@stayathomedev Sure they do!!
@user-px8gk4zf5c
@user-px8gk4zf5c 5 месяцев назад
Man these videos are the best I've ever seen for Godot 4! When I updated from 3.5 to 4 I couldn't figure out anything but these videos helped so much! Hahah also I was just wondering why I was getting the red overlay and figured out it was because I didn't save the state script! I was trying to fix it for like 15 minutes.😂👍
@Bigsperg
@Bigsperg 5 месяцев назад
this actually just taught me state machines. lol thank you
@stayathomedev
@stayathomedev 5 месяцев назад
Awesome!
@moe__dev
@moe__dev 9 месяцев назад
Damn Nice!!
@stayathomedev
@stayathomedev 9 месяцев назад
Thanks!
@GodotPulse
@GodotPulse 26 дней назад
ERR: could not find type "State" in the current scope, any ideas? everything seems to be laid out fine
@sill.k8272
@sill.k8272 7 месяцев назад
i was about to ask but i eventually fixed it, thanks for your tutorials
@hermest99
@hermest99 День назад
What I don't really get is why you use the Walking state script o check if you're supposed to go to Idle manually, and also from Idle to Walking. Why not check for movement in Walking and for standing still in Idle? Wouldn't that be why we did this in the first place?
@ThatGauss
@ThatGauss 6 месяцев назад
Hey my state isn't showing up in the debug panel, what do I do to fix this?
@RushedYT
@RushedYT 2 месяца назад
at the end my debug panel isnt updating my state, it's stuck on Idle but im not sure if my debug panel is the issue or if its my statemachine, how can i fix that?
@tenofhearts99
@tenofhearts99 2 месяца назад
Mine is spazzing out and I can't read it
@hazwanmohaimin4824
@hazwanmohaimin4824 2 месяца назад
@@tenofhearts99 I think the spazzing part, is the order of debug panel, since the video put 1, it causes spazzing you mention, I put it on 5, it's much better
@youcantseemeXD
@youcantseemeXD 2 месяца назад
hey, great tutorials. They help a ton. One question, my state isn't changing when i move. I think my _update function isn't triggering in my states. Any ideas on how to fix it? edit: make sure you have an underscore before all calls on exit(), enter(), and update(), otherwise it calls the wrong function
@baku3435
@baku3435 Месяц назад
Hi I know this video is not very recent, but could using a singleton for player variables affect other player character variables when using it for a multiplayer game?
@robertmiller9569
@robertmiller9569 7 месяцев назад
Can you please help with the errors? The parameter "delta" is never used in the function "physics_update()". If this is intended, prefix it with an underscore: "_delta". UNUSED_PARAMETER state.gd:16
@Legit_SuperFall
@Legit_SuperFall 7 месяцев назад
thats odd, that's usually only a warning you probably fixed it by now, but did adding the underscore fix it?
@werqak
@werqak Месяц назад
I might not understand or have not done something, as I don't see my fps in the debug panel anymore. Help?
@nalan122
@nalan122 2 месяца назад
5:45 wouldn't a static variable do the job too?
@vortexgaming4590
@vortexgaming4590 2 месяца назад
Identifier "transition" not declared in current scope. Help plz :)
@TheSpeedyBoi
@TheSpeedyBoi 9 месяцев назад
Question: I am getting the "Invalid call. Nonexistent function 'enter' in base 'Nil'." error whenever I try to run the scene. My working theory is that CURRENT_STATE is not set to anything by default, yet the same code seems to work in the video? Please advise.
@TheSpeedyBoi
@TheSpeedyBoi 8 месяцев назад
Answer: I forgot to set "Current State" In the inspector to be set to idle by default. Never used that feature before this series so no wonder I didn't know what was wrong :P
@general_jacob8949
@general_jacob8949 8 месяцев назад
@@TheSpeedyBoi thank you so much for taking the time to make this comment. I did not realize that I also missed that instruction as I was going.
@AntonioRColon
@AntonioRColon 6 месяцев назад
This helped so much! Thank you, @@TheSpeedyBoi!
@user-yf5un7kj1p
@user-yf5un7kj1p 9 месяцев назад
very cool
@SlimyMcTee
@SlimyMcTee 3 месяца назад
On the debug info, the state keep staying as idle if I move it. When I check the debugger, I got the warning about "State machine contains incompatible child node". I'm pretty sure I've followed the instructions, and the same people that got the problem here either got unknowingly fixed or still haven't receive any answer.
@stayathomedev
@stayathomedev 3 месяца назад
Make sure all child nodes are using the State class
@SlimyMcTee
@SlimyMcTee 3 месяца назад
@@stayathomedev Yep I did making sure they are using the same State class
@YourComputer
@YourComputer 8 месяцев назад
How come many Godot videos on state machines are creating their own state machines from scratch?
@faadasticman9026
@faadasticman9026 9 месяцев назад
*Is it the same state machine , like we have Finite state automata , in theory of computation?*
@nwarestudios4586
@nwarestudios4586 6 месяцев назад
yes
@crosshudson8714
@crosshudson8714 3 месяца назад
Anybody else having issues with class_name? In the "Attach Node Script" screen I don't see an option for class name. I put class_name in my script but when I inherit from state .gd it does not create the new class automatically. Do I have to enable class names in my project settings or something?
@hery8148
@hery8148 7 месяцев назад
How make state for differents characters like team fortress 2 or overwatch and is it possible to not work on animation with state or it's already the case with the mesh and collision shape or it's not and 1 model with skeleton3D is needed
@Z1RRO-nl1ej
@Z1RRO-nl1ej 5 месяцев назад
I got an error in CURRENT_STATE.enter(). Invalid call. Nonexistent function enter in base Nil
@stayathomedev
@stayathomedev 5 месяцев назад
Make sure you set your Current State in the script export variable in the inspector.
@Z1RRO-nl1ej
@Z1RRO-nl1ej 5 месяцев назад
I have one question: do I need to create state machine if I already have state flags in my player controller? (For example walking = true, etc.)
@stayathomedev
@stayathomedev 5 месяцев назад
Flags can work for simple setups but a full machine will make it MUCH easier to organize your logic in the future.
@tenofhearts99
@tenofhearts99 2 месяца назад
My state is not updating in the debug panel. I'm getting a bunch of error stating that delta is never used on the State.gd functions mostly and that "State does not exist" push warning so it looks like whatever state I'm trying to update to doesn't exist?
@stayathomedev
@stayathomedev 2 месяца назад
Off top of my head...check the state names? State node names?
@WasNeverBrandon
@WasNeverBrandon Месяц назад
transition.emit("Insert NODE Name")
@whitenoise8619
@whitenoise8619 Месяц назад
@@WasNeverBrandon Thank youuuuuuuuuu
@Snauzi
@Snauzi 9 месяцев назад
Cool, I've always loved FSM and this is a good example. But debug breaks the hell out, creating endless labels, even if the code seems the same.
@stayathomedev
@stayathomedev 9 месяцев назад
What's happening with the debug code?
@Snauzi
@Snauzi 9 месяцев назад
Solved! I was using double points in the title, which messed up the find_child function
@stayathomedev
@stayathomedev 9 месяцев назад
Awesome! Glad it worked out
@cristianinujazznight3044
@cristianinujazznight3044 4 месяца назад
I really don't understand why using nodes for states.
@120Stevo
@120Stevo 3 месяца назад
I think it is a Godot thing.
@developerdave7775
@developerdave7775 8 месяцев назад
I am currently experiencing my state machine not transitioning states whenever I move, my script and current project settings match this one. I hope somebody has a solution, or an explanation.
@developerdave7775
@developerdave7775 8 месяцев назад
oh, I forgot to connect the child transition signal. Be sure to do this or else stuff breaks!
@SlimyMcTee
@SlimyMcTee 3 месяца назад
Hey I'm having the same issue and I'm pretty sure I already connect the child transition. What else did you did?
@jamesreed361
@jamesreed361 8 месяцев назад
I'm receiving an "invalid Call. Nonexistent function 'connection' in base 'signal' error. It looks like something is wrong with my child.transition.connection(on_child_transition) line in the State_Machine script. Anyone experience this issue and have a solution or an idea where I went wrong? I've gone back through the video twice now and my scripts appear to match up with the tutorial
@jamesreed361
@jamesreed361 8 месяцев назад
I found my typo in this issue (should have been connect instead of connection) but I'm not seeing the CURRENTSTATE change in the debug panel
@glitcher4O4
@glitcher4O4 7 месяцев назад
Same here, plzzz tell if u found something plzzzz
@patrikgranstrom7683
@patrikgranstrom7683 8 месяцев назад
Getting errors complaining about "delta" in the "_process(delta):" Reticle, in "physics_update(delta: float) -> void:" in state.gd, in " func update(delta):" in IdlePlayerState, and in func update(delta):" in WalkingPlayerState. why did this get triggered from the global?
@patrikgranstrom7683
@patrikgranstrom7683 8 месяцев назад
it says it wants an underscore but why?
@adhdGameDev
@adhdGameDev 8 месяцев назад
@@patrikgranstrom7683 same, get these: W 0:00:00:0885 The parameter "delta" is never used in the function "_process()". If this is intended, prefix it with an underscore: "_delta". UNUSED_PARAMETER Reticle.gd:17 W 0:00:00:0893 The parameter "delta" is never used in the function "physics_update()". If this is intended, prefix it with an underscore: "_delta". UNUSED_PARAMETER state.gd:13 W 0:00:00:0895 The parameter "delta" is never used in the function "update()". If this is intended, prefix it with an underscore: "_delta". UNUSED_PARAMETER IdlePlayerState.gd:4 W 0:00:00:0897 The parameter "delta" is never used in the function "update()". If this is intended, prefix it with an underscore: "_delta". UNUSED_PARAMETER WalkingPlayerState.gd:5 in these Reticle.gd func _process(delta): adjust_reticle_lines() state.gd func physics_update(delta: float) -> void: pass IdePlayerState func update(delta): if Global.player.velocity.lenght() > 0.0: transition.emit("WalkingPlayerState") WalkingPlayerState func update(delta): if Global.player.velocity.lenght() == 0.0: transition.emit("IdlePlayerState") im kinda stuck..
@jasonwilliams8730
@jasonwilliams8730 9 месяцев назад
👍
@issaissa7240
@issaissa7240 6 месяцев назад
Hello that's look working for me, but i don't think really understant all this stuff
@glitcher4O4
@glitcher4O4 7 месяцев назад
Bro i don't know but my state isn't changing
@stayathomedev
@stayathomedev 7 месяцев назад
What's the problem?
@glitcher4O4
@glitcher4O4 7 месяцев назад
@@stayathomedev My CURRENT STATE isn't changing in debug panel , it always stays Idle,
@stayathomedev
@stayathomedev 7 месяцев назад
Does it change at all or just not in the debug?
@glitcher4O4
@glitcher4O4 7 месяцев назад
Thanks for asking but fortunately I fixed it and still don't know what was wrong at that time I really appreciate the series please keep going
@nibelheimnixxus
@nibelheimnixxus 7 месяцев назад
@@glitcher4O4 what was your fixed? I have a similar issue
@glitcher4O4
@glitcher4O4 7 месяцев назад
Plzzzz help
@aryantzh2028
@aryantzh2028 9 месяцев назад
lmao, my comment got deleted
@KingOfFoolz
@KingOfFoolz 9 месяцев назад
What was it?
@rumariomusic
@rumariomusic 9 месяцев назад
Too little content. If you continue publishing your videos at this rate, it will be 2026 until your FPS is ready and your Godot videos are all out of date again.
@foureggsinafryingpan3870
@foureggsinafryingpan3870 9 месяцев назад
Its only a week between videos. Not even that long.
@theodorus956
@theodorus956 9 месяцев назад
​@@foureggsinafryingpan3870true, he's just hatin' for no reason
@JustSpaceMan1
@JustSpaceMan1 3 месяца назад
I'm getting an "Invalid call. Nonexistent function 'exit' in base 'Node (IdlePlayerState)." when I walk forward, and the scene closes. I'm not sure why, I assume I missed something, or it's covered in the next video. Edit: I may have fixed the problem. At CURRENT_STATE.exit(), I put an underscore in front of exit and it works. -> CURRENT_STATE._exit().
@stayathomedev
@stayathomedev 3 месяца назад
What script do you have in the IdlePlayerState node?
@JustSpaceMan1
@JustSpaceMan1 3 месяца назад
@@stayathomedev The IdlePlayerState one.
@JustSpaceMan1
@JustSpaceMan1 2 месяца назад
@@stayathomedev Strangely, putting an underscore at .exit() seems to have fixed the problem.
@Legit_SuperFall
@Legit_SuperFall 7 месяцев назад
Everything is working, but i'm getting "Player State: Idle_PlayerState: " I wish it didnt show the node. idk why it's there
@FullBitGamer
@FullBitGamer 4 месяца назад
make sure to add ".name" to the CURRENT_STATE in the debug.add_property script! EXAMPLE: #global script name here!!.debug.add_property("Current State", CURRENT_STATE.name, 4)
Далее
would you eat this? #shorts
00:35
Просмотров 819 тыс.
💀СЛОМАЛ Айфон за 5 СЕКУНД😱
00:26
Blender to Godot Workflow
6:15
Просмотров 2,5 тыс.
Now anyone can simulate flow for a 3D printer duct
11:17
Godot Debugging Techniques EVERY Dev Should Know
16:23