Тёмный

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

Comp-3 Interactive
Подписаться 16 тыс.
Просмотров 41 тыс.
50% 1

Hey guys! Today we're going to be adding in some headbob settings to our first person controller! If that sounds interesting to you then watch on! If not... watch on anyway!
Join me and learn your way through the Unity Game Engine, the C# language and the Visual Studio editor. Remember, if this video was useful then DROP A LIKE! 👍
🤩 SPONSORED LINKS:
www.gigatank30...
/ gigatank3000
Check out HEXED PERSPECTIVE:
Soundcloud: / hexmane
Spotify: open.spotify.c...
Instagram: www.instagram....
Apple Music: / hexmane
💯 Want to help me out and allow me to keep making these tutorials? Consider supporting the channel on Patreon:
/ comp3interactive
😍 AWESOME high quality 3D game assets available here:
shop.runemarks...
💬 Join the Discord community here:
/ discord
📱 Find us on social media for more Tips and Tricks:
/ comp3interactive
/ comp3interactive
/ comp3int
📱 Play our games for FREE here on Google Play:
bit.ly/2TisAQo
#UnityTutorial #Unity3D #Comp3interactive #GameDev

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

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 98   
@monkeyrobotsinc.9875
@monkeyrobotsinc.9875 Год назад
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.
@Savaril
@Savaril 2 года назад
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 11 месяцев назад
Same! This guy is actually such a chad
@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.
@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!!!!
@brick1488
@brick1488 Год назад
actually amazing help me very much keep up the good work
@PlayBAT
@PlayBAT 8 месяцев назад
Dude, you're the best! No one on RU-vid can explain it so clearly!👍
@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!
@qroundhawk7149
@qroundhawk7149 2 года назад
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.
@swzwij
@swzwij 3 года назад
Could you also do an episode where you implement foot steps into the character controllers
@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! 😂
@sumgue4964
@sumgue4964 3 месяца назад
8:43 this tutorial be bumping broooo 😂
@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 2 года назад
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 2 года назад
@@KH2FanLover Worked, thanks!
@qroundhawk7149
@qroundhawk7149 2 года назад
@@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 2 года назад
@@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; }
@lumberapple8820
@lumberapple8820 Год назад
Thank you, you are a saint. This worked perfectly and i actually understand what you are saying :). Subbed!
@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.
@priestartor9065
@priestartor9065 2 года назад
Thanks this was simple and just what I was looking for
@H1zoneTv
@H1zoneTv 3 года назад
Man you one of the bests!!!
@joshuahillary3312
@joshuahillary3312 2 года назад
So glad Tyson Fury is teaching me unity
@comp3interactive
@comp3interactive 2 года назад
First time I've had that one... I've had Sean Bean and Kane from WWE but never Tyson Fury 😂
@tincoES
@tincoES Год назад
amazing tutorials dude thanks a lot...
@anfrollex
@anfrollex Год назад
Keep it up! Amazing!
@qazmyas9727
@qazmyas9727 2 года назад
Thank you! Great tutorial!
@estebanruiz6764
@estebanruiz6764 Год назад
great tutorial, thank you
@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!
@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
@koferperk
@koferperk 3 года назад
very cool! thanks man
@veteranfighter69
@veteranfighter69 3 года назад
Great video, keep on!
@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.*
@AlejandroArch22
@AlejandroArch22 2 года назад
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.
@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!
@Bat_pann
@Bat_pann 3 года назад
Perfect.
@featherless656
@featherless656 2 года назад
I did everything in the tutorial, but instead of bobbing, it just kinda doesn't do anything
@jud.su.5developer895
@jud.su.5developer895 2 года назад
You are great 👍🏿
@KIXEMITNOG
@KIXEMITNOG 3 года назад
Nice!
@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 RU-vid 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
@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 9 месяцев назад
@@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 9 месяцев назад
Thanks!@@TheMavryan
@gerritson7178
@gerritson7178 Год назад
how do I make it go a little to side
@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(), ....
@grooviss619
@grooviss619 Год назад
Camera wont return to defaultYPos. Any ideas?
@MarsLaaars
@MarsLaaars Год назад
same for me also
@MarsLaaars
@MarsLaaars Год назад
fixed it 😅, I had written 'defaultYPos = Mathf.Sin(timer)' instead of "defaultYPos + Mathf.Sin(timer)"
@ИсламКаримов-т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;
@MrReallefauve
@MrReallefauve 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.
@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..
@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.
@The-Cheph
@The-Cheph 2 года назад
I did everything right and its not headbobbing
@The-Cheph
@The-Cheph 2 года назад
no errors
@t0xangames207
@t0xangames207 Год назад
5:52 Vector3.magnitude.....
@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 8 месяцев назад
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
Далее
РЫБКА С ПИВОМ
00:39
Просмотров 521 тыс.
Why Stairs Suck in Games... and why they don't have to
11:24
How to make The Best First Person Camera in Unity
9:04
3 Months of Learning Game Development
10:48
Просмотров 959 тыс.
THIRD PERSON MOVEMENT in Unity
21:05
Просмотров 1,4 млн
How I Would Start Game Development (If I Started Over)
16:59
UNITY ScriptableObject Basics
13:55
Просмотров 19 тыс.