E12 - Sliding // Make An FPS in Godot 4

preview_player
Показать описание

-----------------------------------------------------------------------------------

-----------------------------------------------------------------------------------

0:00 The Godot FPS Project
0:26 The Sliding State
1:39 Set Tilt Function
3:00 Sliding State Script Continued
3:46 Sliding Animation
4:11 Animation Values
5:30 Finishing Sliding Script
6:08 State Transitions
7:48 Final Results
8:18 More Tutorials

-----------------------------------------------------------------------------------

This series is part of my sponsored Godot FPS Project where we will walk through how to create an 3D FPS game in Godot 4, step by step. I won't be skipping any steps in the process and everything will be sequential video to video.

This initial basic FPS setup project is available for free to download and use using the MIT license via the link below. For all future videos, the project source files will be available to my GitHub Sponsors.

Joining my Patreon in one of the 3 tiers will give you:

- access to the private Discord channel
- your name in the project README
- early access to tutorial videos
- power to vote on what mechanics get covered in future videos
- full access to the project source files to use in your own projects

-----------------------------------------------------------------------------------

#godot #godotengine #fps
Рекомендации по теме
Комментарии
Автор

Final tutorial of the year! Tons more coming in 2024. Thanks for watching everyone!

stayathomedev
Автор

For anyone that was confused as I was on how to do the “SlidingPlayerState” Animation around 4:54 in the youtube video :

For the SPEED animation track:

1 Select the “fps_controller” scene
2 On the left hand side in the “Scene” tab, click on the AnimationPlayer Node “AnimationPlayer”
3 In the “Animation” bottom panel, select the “Sliding” Animation from the drop down selection
4 click on “+ Add Track” and select “Property Track”
4.1 A new Window called “Pick a node to animate” will open
4.2 Select the “SlidingPlayerState” node and select “OK”
4.3 Another new Window called “Select Property” will open
4.4 Select the “SPEED” variable and select “Open”.
5 A new “SlidingPlayerState” Node track with a “SPEED” track will appear in the Animation bottom panel
6 Under the “SlidingPlayerState” Node Track select the animation track for “SPEED”
7 Right-click on the track for “SPEED” at the 1 second mark and select “Insert Key...”,
7.1 Left click on the 1 second mark you just added,
7.2 On the right hand side in the “Inspector” tab under “AnimationTrackKeyEdit”, in the “Value” field enter 6,
8 Right-click on the track for “SPEED” at the 5 second mark and select “Insert Key...”,
8.1 Left click on the 5 second mark you just added,
8.2 On the right hand side in the “Inspector” tab under “AnimationTrackKeyEdit”, in the “Value” field enter 4


For the finish function/method animation track:


1 Select the “fps_controller” scene
2 On the left hand side in the “Scene” tab, click on the AnimationPlayer Node “AnimationPlayer”
3 In the “Animation” bottom panel, select the “Sliding” Animation from the drop down selection
4 click on “+ Add Track” and select “Call Method Trackl...”
5 A new Window called “Pick a node to animate” will open
5.1 Select the “SlidingPlayerState” node and select “OK”
6 A new track called “Functions:” will appear under the “SlidingPlayerState” track
7 Right-click on the track for “Functions:” at the 5 second mark and select “Insert Key...”,
7.1 A new window called “Select Method” will open
7.2 Under “Script Methods” look for the Method/Function “void finish()” (it’s the same finish() function from “SlidingPlayerState”) select “OK”

emacadam
Автор

For anyone lost in the end, here is the complete (new) uncrouch function:

func uncrouch():
if == false:
ANIMATION.play("Crouching", -1.0, -CROUCH_SPEED, true)
await ANIMATION.animation_finished
if PLAYER.velocity.length() == 0:

else:

elif == true:
await
uncrouch()

eight
Автор

Where is the previous state parameter coming from? I get the idea, but hard to implement when its comes out of nowhere..

Tbh, this episode is generally just bad. A lot of complaints about people having trouble with the code, and because the code is behind a paywall, there is no way to see whats missing.

Snapper-gaming
Автор

Though I'm glad this tutorial exists, this episode highligths its shortcoming even more than previous episodes:
Quickly glossing over essential information, doing very little explaining of the "why", staying on essential parts of the code for half a second or cropping it completely (the Uncrouch method is incomplete, had to figure it out myself, like someone did in the comment)
So the goal here it to make it frustrating enough that we are forced to go through the paywall.
This is monetised, so I get it, but it is annoying nonetheless.

loconeko
Автор

i can't seem to put "previous_state" in the parentheses at "enter()" without getting an error. it says "the function signature doesn't match the parent"

Marshimized
Автор

to easily find out what animation path has what number (for when you set the camera tilt), i used the code blow to easily print all tracks. use it in the slide code or wherever and it'll do it's thing, letting you know what number to put into the function. 

for i in range(0, 8):
print(str(i) + ": " +

Note: you can change the top of the range based on how many tracks you have in your sliding animation

hermest
Автор

Finally, sliding 🤧🤧🤧. good job Man. Happy new year to you 👍🏾

Revampness
Автор

7:25 I can see that func uncrouch() code is different and it cuts off some of it, so I can't copy it... Also SprintingPlayerState has a "%" for a Unique Name next to it - what's that for? Anyway, I'm entering the Sliding State and I just stay in it - I don't exit from it. Very confusing.

EDIT: I'll skip the sliding for now, maybe I'll come back to it later.

BrentonWoods
Автор

looks like there are some changes to the uncrouch function not covered?

rugia
Автор

Can someone help please with the tutorial part at 1:23 he glosses over it so fast that I just can't seem to figure it out.

christianpelczarski
Автор

If anyone still having a problem with the finish() function not showing up in the Call Method window try closing and re-opening godot, worked for me

TrippingPanda
Автор

I got confused and broke the crouch and slide mechanic

Well time to make up my own script >__<

cernos
Автор

For some reason at the end of the animation it's like the camera snaps back to place and makes the animation look choppy, I assume it's an issue with the animation but I checked all points and even when they're the same as yours I have this issue.

Edit: Nevermind I realised I had crouch animation named "Crouch" but used "Crouching" when assigning current_animation

bigboibob
Автор

how to make it so that sliding is not available when running backwards and so that the sliding speed gradually decreases?

secret.message.
Автор

how do you add the function to the animation

GodlessTramp-tqrd
Автор

Why use animations when sliding as opposed to procedurally adjusting the camera?

bioburden
Автор

is there a schedule/ plan that youre following? itd be great to see whats up coming.

patrickkawa
Автор

@stayathomedev holding crouch works but after a slide attempting to uncrouch causes it to jump to the top of the crouch, go back down about 0.2m and finish the uncrouch, from other states work just fine, somewhere between and uncrouch() it breaks my state IS named "CrouchPlayerState" ive quad checked typos and im using the same code, excluding cam tilt

ddrruwu
Автор

I am stuck so bad it does the sliding thing but my character does not actually go forward

CasualRandom