First Person Controller - Headbob (EP05) [Unity Tutorial]

  Рет қаралды 42,265

Comp-3 Interactive

Comp-3 Interactive

Күн бұрын

Пікірлер: 100
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 2 жыл бұрын
you are such a great instructor. most people would just say "then we type this" but you explain the most important part: the WHY. you da best. and you are a great coder. ive already learned so many cool new tricks and things ive never picked up from tons of videos already. thank you.
@Selfency
@Selfency Жыл бұрын
Cannot agree more. When watching other "tutorials" they don't care to teach you, it's basically just "copy this and run it" like, bro I can copy and paste code all day that isn't going to make me understand it. Meanwhile, this guy has the most organized and comprehensive workflow out of them all and explains it better than anyone else either. Cannot thank him enough.
@Zygmuntt
@Zygmuntt 3 жыл бұрын
Absolute chad! Thanks a lot, this is the only tutorial I could find that isn't half an hour long and works.
@Savaril
@Savaril 3 жыл бұрын
Thank you for this tutorial, it's the only one I could find on youtube that actually produced good results that were feasible for a real game and not just a demo
@IAmViolencity
@IAmViolencity Жыл бұрын
Same! This guy is actually such a chad
@TheBackroomsSmiler
@TheBackroomsSmiler 11 күн бұрын
As a beginner to c#, your tutorials are amazing, tysm
@liornaveh192
@liornaveh192 Жыл бұрын
Its my first time in Unity and i wanted to make a FPS game and your tutorials are so good so thank u so much bro!!!!
@PlayBAT
@PlayBAT 10 ай бұрын
Dude, you're the best! No one on KZbin can explain it so clearly!👍
@qroundhawk7149
@qroundhawk7149 3 жыл бұрын
This series is amazing, keep up the good work men. Hoop this channel blows up for tutorials because you explain it so clearly and calm.
@WizardMonke
@WizardMonke 2 жыл бұрын
Love your tutorials. The code is organized and satisfying to write, and I love the flexibility that you've given this controller to really be used in any FPS. Also you explain things very concisely and clearly. Keep up the good work!
@Wheiejdj27383
@Wheiejdj27383 Жыл бұрын
actually amazing help me very much keep up the good work
@swzwij
@swzwij 3 жыл бұрын
Could you also do an episode where you implement foot steps into the character controllers
@168games-i6p
@168games-i6p 25 күн бұрын
Thank you for teaching us, I wish you the best!
@sumgue4964
@sumgue4964 5 ай бұрын
8:43 this tutorial be bumping broooo 😂
@Rise2034
@Rise2034 3 жыл бұрын
I hate the youtube algorithm!🤬 you deserve wayyyy more view and like! anyway just keep it mind that this is so great its help me a lot every time!
@comp3interactive
@comp3interactive 3 жыл бұрын
Thanks man, that means a lot! Glad it's helping! I'm slowly creeping up in my analytics so hopefully soon enough I'll get a video that booms! 😂
@H1zoneTv
@H1zoneTv 3 жыл бұрын
Man you one of the bests!!!
@joshuahillary3312
@joshuahillary3312 3 жыл бұрын
So glad Tyson Fury is teaching me unity
@comp3interactive
@comp3interactive 3 жыл бұрын
First time I've had that one... I've had Sean Bean and Kane from WWE but never Tyson Fury 😂
@lumberapple8820
@lumberapple8820 Жыл бұрын
Thank you, you are a saint. This worked perfectly and i actually understand what you are saying :). Subbed!
@priestartor9065
@priestartor9065 2 жыл бұрын
Thanks this was simple and just what I was looking for
@zbeb118
@zbeb118 3 жыл бұрын
Hey, great video but there is just one little bug, with this current bob it only moves the camera when the movedir.x or movedir.z are > 0.1 so if you move just a bit the camera moves down a bit stays down and doesnt move back up until you start moving again. Is there any work around?
@KH2FanLover
@KH2FanLover 3 жыл бұрын
On the ''HandleHeadbob'' void, after the second if, put this: else { timer += Time.deltaTime * (isCrouching ? crouchBobSpeed : IsSprinting ? sprintBobSpeed : walkBobSpeed); playerCamera.transform.localPosition = new Vector3(playerCamera.transform.localPosition.x, defaultYPos, playerCamera.transform.localPosition.z); }
@Heperoo
@Heperoo 3 жыл бұрын
@@KH2FanLover Worked, thanks!
@qroundhawk7149
@qroundhawk7149 3 жыл бұрын
@@KH2FanLover You should make another check: else if(defaultYPos != playerCamera.transform.localPosition.y) so the else wont be called every frame only once to bring it back to defaultYPos
@KH2FanLover
@KH2FanLover 3 жыл бұрын
@@qroundhawk7149 Oh true! Thanks!
@bshaun2740
@bshaun2740 2 жыл бұрын
@@KH2FanLover To add on to this even more, here's some code to make the return to the default height smoother. Create your own float variable for the animation speed and name it (timeToReturn), then run this coroutine on the third if statement (the one provided by Qroundhawk) to interpolate the vectors return to the default height value. Here's the code: private IEnumerator LevelHeight() { if (duringCrouchAnimation) { yield break; } duringLevelHeightAnimation = true; float timeElapsed = 0; Vector3 currentHeight = playerCamera.transform.localPosition; Vector3 targetHeight; targetHeight = new Vector3(playerCamera.transform.localPosition.x, defaultYPos, playerCamera.transform.localPosition.z); while (timeElapsed < timeToReturn) { playerCamera.transform.localPosition = Vector3.Lerp(currentHeight, targetHeight, timeElapsed / timeToReturn); timeElapsed += Time.deltaTime; yield return null; } duringLevelHeightAnimation = false; }
@tincoES
@tincoES Жыл бұрын
amazing tutorials dude thanks a lot...
@anfrollex
@anfrollex Жыл бұрын
Keep it up! Amazing!
@veteranfighter69
@veteranfighter69 3 жыл бұрын
Great video, keep on!
@estebanruiz6764
@estebanruiz6764 2 жыл бұрын
great tutorial, thank you
@qazmyas9727
@qazmyas9727 2 жыл бұрын
Thank you! Great tutorial!
@koferperk
@koferperk 3 жыл бұрын
very cool! thanks man
@Bat_pann
@Bat_pann 3 жыл бұрын
Perfect.
@AlejandroArch22
@AlejandroArch22 3 жыл бұрын
When i first start walking with the headbob enabled For some reason It lowers my hieght. Not sure if its the characterController hieght or the playerCamera height.
@ike7093
@ike7093 Жыл бұрын
When ever I move the camera moves down to the center of the player. When ever I couch... I cannot uncrouch. Help please
@rebornkevin7874
@rebornkevin7874 3 жыл бұрын
I'm sort of a new person to Unity and these videos have helped me a lot, just a question if you don't mind. Any plans to make a tutorial on how to make footsteps SFX? Like whenever you walk a sound effect plays such as wood creaking, concrete?
@comp3interactive
@comp3interactive 3 жыл бұрын
For sure man. That's going to be one of the episodes in the series!
@rebornkevin7874
@rebornkevin7874 3 жыл бұрын
@@comp3interactive Amazing! I can't wait for that tutorial, I'm attempting to do a PS1-styled horror game and stumbled upon your channel. Thank you so much for this.
@gerritson7178
@gerritson7178 Жыл бұрын
how do I make it go a little to side
@jud.su.5developer895
@jud.su.5developer895 2 жыл бұрын
You are great 👍🏿
@KIXEMITNOG
@KIXEMITNOG 3 жыл бұрын
Nice!
@vieirapereira1298
@vieirapereira1298 3 жыл бұрын
hey! great video once again! following and learning this controller! but i ran into a bug, as i walk my camera goes to the middle of the capsule and doesnt return. it does the bob from there, is very weird. i tried disable the crouch and nothing, can someone help ?
@IlIlIIIIlIlIIlIll
@IlIlIIIIlIlIIlIll 2 жыл бұрын
did you find a fix?
@skaruts
@skaruts 2 жыл бұрын
Check where you set the *defaultYPos* inside *Awake,* to see if you didn't use *position* instead of *localPosition* by mistake. It should be *localPosition.*
@KushagraPratap
@KushagraPratap 3 жыл бұрын
I subscribed for you accent, and I dont regret it. Please give some tips for first person games to look more alive
@comp3interactive
@comp3interactive 3 жыл бұрын
You know, the thing that stopped me from starting up a KZbin channel sooner was my voice. I didn't think it was that easy to understand, especially to a foreign audience, but I haven't had many negative comments about it and also my analytics show only 6% use subtitles... Learn to love yourself ♥ 😂
@comp3interactive
@comp3interactive 3 жыл бұрын
In regards to more FPS tutorials, once this controller series is fleshed out then we'll be using this controller in further FPS tutorials. It just seemed logical to get the controller completed first
@KushagraPratap
@KushagraPratap 3 жыл бұрын
@@comp3interactive I used to watch with someone similar accent, LaffenGas, a minecraft youtuber, and I still watch him not bcoz I like his content, but just bcoz his accent, its kinda addicting
@comp3interactive
@comp3interactive 3 жыл бұрын
You'll have to join a drunken Live stream at some point after I've moved house... After a few drinks my voice gets a lot broader 😂
@KushagraPratap
@KushagraPratap 3 жыл бұрын
@@comp3interactive lol
@poseidon5602
@poseidon5602 3 жыл бұрын
Are you going to make full body fps controller like adding hands,legs ,body?
@comp3interactive
@comp3interactive 3 жыл бұрын
I can definitely add an episode where we add it the body mesh!
@poseidon5602
@poseidon5602 3 жыл бұрын
@@comp3interactive Ok thank you ! I am waiting
@comp3interactive
@comp3interactive 3 жыл бұрын
If you're new here then just a heads up, there might be a little gap in uploads soon because I moved house yesterday, but I'll be back as soon as I get my office set up!
@grooviss619
@grooviss619 2 жыл бұрын
Camera wont return to defaultYPos. Any ideas?
@MarsLaaars
@MarsLaaars 2 жыл бұрын
same for me also
@MarsLaaars
@MarsLaaars 2 жыл бұрын
fixed it 😅, I had written 'defaultYPos = Mathf.Sin(timer)' instead of "defaultYPos + Mathf.Sin(timer)"
@featherless656
@featherless656 2 жыл бұрын
I did everything in the tutorial, but instead of bobbing, it just kinda doesn't do anything
@rycrft
@rycrft 3 жыл бұрын
Just a question, since being new to scripting and such I am learning lot's from this! But is it okay to use your same script for a published game in the future?
@comp3interactive
@comp3interactive 3 жыл бұрын
Yeah man for sure, use it, tweak it, just learn from it... Do whatever you like with it
@rycrft
@rycrft 3 жыл бұрын
@@comp3interactive Perfect! Thank you very much! Great vids! Also one more question, would you be able to do a prone script?
@comp3interactive
@comp3interactive 3 жыл бұрын
It's on my "to do" list, I'm just taking a little break from recording at the moment but I should be back at it soon enough
@rycrft
@rycrft 3 жыл бұрын
@@comp3interactive No worries! Take your time!
@trapeface
@trapeface Жыл бұрын
For others who find themselves expanding on the technique... Left as-was for my purposes, just a "thought for food"....almost gave up the troll-ish share for format/clarity grief- protected float MatchParameter(string context = null) { if(context == "bob") return isSprinting ? _sprintBobSpeed : _isCrouching ? _crouchBobSpeed : _walkBobSpeed; return isSprinting ? _sprintSpeed : _isCrouching ? _crouchSpeed : _walkSpeed; } // which allows in head bob method: timer += Time.deltaTime * MatchParameter("bob"); // elsewhere _currentInput = new Vector2(Input.GetAxis("...") * MatchParameter(), ....
@Snai1TankProductions
@Snai1TankProductions 2 жыл бұрын
My headbob is happening even when I'm standing still... Have I missed something?
@timtrollgasm
@timtrollgasm Жыл бұрын
Yeah I got that issue too. did you ever get it fixed? If so how?
@TheMavryan
@TheMavryan 11 ай бұрын
@@timtrollgasm Hey, I just got this issue and realised I had put a semi colon on the end of if (Mathf.Abs(moveDirection.x) > 0.1f || Mathf.Abs(moveDirection.z) > 0.1f) Once I removed the semicolon then the bobbing worked correctly when idle. Hopefully this helps!
@timtrollgasm
@timtrollgasm 11 ай бұрын
Thanks!@@TheMavryan
@CHTOUROU_BECHIR
@CHTOUROU_BECHIR 3 жыл бұрын
I agree with "Rise 2034", the number of views is not fair considering the quality of the tutorials, I find it weird, I know a certain Englishman who has a tutorial channel and who has more than 120k of subscribers and I know his lessons suck, needless to say who he is (he does sequencing and not programming ...) and yet he has so many subscribers !!!!! It is unfair.
@t0xangames207
@t0xangames207 Жыл бұрын
5:52 Vector3.magnitude.....
@ИсламКаримов-т9ь
@ИсламКаримов-т9ь 3 жыл бұрын
hey man very good code but you need make "isCrouching ? crouchBobSpeed : IsSprinting ? sprintBobSpeed : walkBobSpeed" as property like below float BobSpeed => isCrouching ? crouchBobSpeed : IsSprinting ? sprintBobSpeed : walkBobSpeed;
@souldarktemplar
@souldarktemplar Жыл бұрын
Greetings, I have followed your tutorial as best as I can, not exactly 'verbatim', but I tried to cram all the technics and insight and stuff in my head but I am just absolutely stumped one single thing. The headbob doesn't seem to trigger for when crouching. Any other movement, walking, sprinting works but not crouching. I have tried logging if my isCrouching is being finicky but so far it has not been that way, especially when the part that checks for any ceiling while crouching works as intended. May I ask for any comment on this? I could leave it as is and just animate whatever stuff the player would be holding as I am assuming the player shall be holding a weapon or item for most if not all of the time but I would really like to see it fixed so I may feel it out and stuff.... Thank you in advance..
@The-Cheph
@The-Cheph 2 жыл бұрын
I did everything right and its not headbobbing
@The-Cheph
@The-Cheph 2 жыл бұрын
no errors
@internalreadonlyvoid5283
@internalreadonlyvoid5283 3 жыл бұрын
Cool tut. But Having one script that controls everything... Not good. Yes, u can disable some features...
@thepolygonpilgrimage
@thepolygonpilgrimage 3 жыл бұрын
What in your opinion would be better? Too many tiny scripts becomes cumbersome. IMO a master script for a player controller makes perfect sense; contain all player functions to one place. Otherwise to make sweeping changes or even simple ones you would need to go all over the place. This is far less messy and far more efficient.
@comp3interactive
@comp3interactive 3 жыл бұрын
I know what you mean but I disagree with that in this instance. If it becomes too large then it can be split up to partials but for a single entity such as a first person controller it's fine to contain everything in a single master class, it cuts down on local references to other sub-classes which you need to monitor on scene change to make sure they're still intact
@LitNotFig
@LitNotFig 2 жыл бұрын
Its not working, I checked the code and its exactly the same.
@KalebShewangizaw-b7i
@KalebShewangizaw-b7i Жыл бұрын
Plis c# script
@LitNotFig
@LitNotFig 3 жыл бұрын
It is going way too fast
@comp3interactive
@comp3interactive 3 жыл бұрын
Slow it down then, there's speed variables right there in the inspector
@gaspardfrancois7139
@gaspardfrancois7139 2 жыл бұрын
doesn't fucking work i have 43 errors
@comp3interactive
@comp3interactive 2 жыл бұрын
Lol. So you mean YOUR code doesn't work, not the tutorial. Probably follow it again a bit more closely
@gaspardfrancois7139
@gaspardfrancois7139 2 жыл бұрын
@@comp3interactive bruh il gonna kms its faster
@comp3interactive
@comp3interactive 2 жыл бұрын
Nice. Healthy mentality right there
@gaspardfrancois7139
@gaspardfrancois7139 2 жыл бұрын
@@comp3interactive btw how do u type the two weird characters at 5:36?
@comp3interactive
@comp3interactive 2 жыл бұрын
The pipe? It's just a key on your keyboard
@Tammichdrawz
@Tammichdrawz 11 ай бұрын
unfortunately the head bob for sprinting doesnt work i'm floating, { if (!characterController.isGrounded) return; float speedMultiplier = IsSprinting ? SprintWalkSpeed : WalkBobSpeed; // Use the correct variable float headBob = Mathf.Sin(timer * speedMultiplier) * (IsSprinting ? SprintBobAmount : WalkBobAmount); PlayerCamera.transform.localPosition = new Vector3( PlayerCamera.transform.localPosition.x, defaultYPos + headBob, PlayerCamera.transform.localPosition.z ); if (Mathf.Abs(characterController.velocity.x) > 0.1f || Mathf.Abs(characterController.velocity.z) > 0.1f) { timer += Time.deltaTime; } else { timer = 0f; } } is what i'm using but when i used yours it still didnt work
First Person Controller - Slope Sliding (EP06) [Unity Tutorial]
9:55
Comp-3 Interactive
Рет қаралды 28 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 37 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 14 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 16 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,5 МЛН
Full Stack WebDev CoHort 1.0 Launch 🚀 with @chaiaurcode ☕️
23:30
SLOPE MOVEMENT, SPRINTING & CROUCHING - Unity Tutorial
8:45
Dave / GameDevelopment
Рет қаралды 235 М.
Why Stairs Suck in Games... and why they don't have to
11:24
Nick Maltbie
Рет қаралды 1,5 МЛН
FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial
9:58
Dave / GameDevelopment
Рет қаралды 1,1 МЛН
How to Make a Door System in Unity - Unity C# Tutorial
23:55
Omogonix
Рет қаралды 25 М.
First Person Animations With Weapons - FPS Game With Unity & Blender
18:51
Single Sapling Games
Рет қаралды 71 М.
SHOOTING with BULLETS + CUSTOM PROJECTILES || Unity 3D Tutorial (#1)
9:25
Dave / GameDevelopment
Рет қаралды 207 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 37 МЛН