FIRST PERSON MOVEMENT in Unity - FPS Controller
HTML-код
- Опубликовано: 26 окт 2019
- Let's see how to get an FPS Character Controller up and running in no time!
REGISTER with APPTUTTI: www.apptutti.com/partners/reg...
LEARN MORE: www.apptutti.com/corporate/?u...
● Ultimate FPS asset: assetstore.unity.com/packages...
● New Input System: • NEW INPUT SYSTEM in Unity
● FPS Shooting: • Shooting with Raycasts...
····················································································
❤️ Donate: www.paypal.com/donate/?hosted...
► Join Discord: / discord
● Website: brackeys.com/
● Twitter: / brackeystweet
● Instagram: / brackeysteam
····················································································
► All content by Brackeys is 100% free. We believe that education should be available for everyone.
❤️ Donate: www.paypal.com/donate/?hosted...
····················································································
♪ "ES_Dress Code_Black - oomiee" by Epidemic Sound
Yeeey you're finally back! Been waiting for this one! :DDD
Dani Man you’re fast I just got the notification
hi
WHERES MY MOBILE PORTS NERD
Dani your the man, keep up your devlogs my dude.
I played karlson for 2 hours .... idk why
Mr. Brackeys we noobs will always respect you as our teacher. You left RUclips but you cannot leave our hearts, sir.
why is he not responding?
*salut*
may he teach us trough eventually out dated videos
Yash :The Gaming Boy i think he didnt look up his youtube page again
amen
Brackey is a legend. I followed 6 different tutorials in order to make a first person controller, I was starting to give up until I remembered your channel and I followed this video. You are the reason why I haven’t given up game development. Thank you.❤
Exactly the same here!
I have been searching for ages to find a good movement, I am acutaly saying this as unity is loading so I have faith but idk
Really concise, this is the best fps programming tutorial I have seen so far!
4:51 Mouse Controls
11:13 Key Controls
15:14 Gravity
21:21 Jumping
thanks
Let's Make This The Top Comment
Nice. Pin this comment Brackeys!
BRACKEY PIN THIS
Who just liked my comment
I heard that Bethesda offices doesn’t have doors, the staff just clip trough the walls.
Yep that required 100$/year.
@Honey Badger Don't Care yes you are, not joking.
lol you made my day. :D
@@skaruts "People will buy everything" - Todd 2018
Lmaoooooooooooooooooooooooooooooooooooooooooooooooo
4 years in and this is one of the best movement tutorial that I found out there
For sure one of the best Unity how-to’s I’ve come across. You break it down so well and make it easy to follow and understand. Definitely subscribing - thanks!
I think Brackeys is psychic, EVERY SINGLE TIME I am going to start a project, he does a tutorial on the exact type of game it is.
Similar! I think huh what if bracket did first per-
New video 🤔
yeah! what is up with that..?
TheLlamaWaffle He has secretly implanted mind reading devices in our brains through us watching his vids. He then uses unity to see what we want.
I am new here so the most types of game i make are here
What if brackets did a mech game tutorial
me: trying to slowly and methodically type out a script.
brackeys: I AM SPEED.
bruh i have the same problem except i need to set video speed to 1.25 :D
StarzzDrak good for you but.... we didn’t need to know that
@@stupidrobot7386 yes but its life struggle for both of us.. that was the point
@@StarzzDrak Why are you watching a beginner tutorial if you're a more experienced programmer? lol
@@SwedishVikingMCbruh why not ? I haven't created a single 3d character controller in 3 years
brackeys explains things with diagrams before starting to demonstrate, such a gem. this tutorial still make sense up to today, well apart the fact that you will have to consider using the new input system. Thanks a lot! i just hope you will be back one day, in publishing tutorials
Jesus is lord follow him and you will be saved
@@amanewithjesus5244 What's wrong with you?
Worked perfectly after a few hiccups (probably on my end). So much better explained and implemented compared to this other tutorial I followed. Highly recommended!
Unity: "No errors detected!"
Me: Falling through the ground at 5000 miles per hour.
Unity: "No Errors detected"
Me: Jump, no :(
@@p4tk47 same. did you fix it?
how to fix?
@@p4tk47 SAME
do you have a terrain or a plane with a collider on it?
God creating the universe: "..and of course let's multiply with Time.deltaTime".
lol
underrated xd
HAHAHAHA
69th like
@@Aries-tp8sk nice ;)
I'm making a third person controller with the new Input System and Cinemachine. I finally figured out basic movement but I had no clue how to add jump and gravity mechanics. Your method worked perfectly. Thanks mate!
My first in-game code ever written, I did complete an online course of C# so I get the basic stuff and some advanced stuff but application in the engine is beyond me. Super helpful tutorial, very happy I found this, Thank You!!!!
Make sure you add the camera as a child object to the player
Brackeys is a life saver :D
Me: *Runs into an error*
Me: *Stairs blankly at my code*
Brain: "Just look up the error on google"
Me: *continues to stair blankly at my code*
Brain: "JUST LOOK IT UP"
Me: "Yeah. your right... Time for a new project"
I dunno if you will find it helpfull but with F5 you can run the code and in bottom console it will show you errors
Alt + f4 I believe is good
@@bobdagamer640 For a split second, i went "Huh I didn't know they could do tha-- wait a second...
Lol
I forgot a comma when that almost happened
me: sees "quaternion"
me: "ok so basically its black magic and i dont need to know how it works"
It is in fact one of the coplex parts of game dev you are better off not diging into it if you don't want your head to hurt
@@youneskasdi i did an oopsie... i dug into it
you weren't wrong, my head hurts
@@dzvidea5065 same here
@@youneskasdi I read an article about it and understand absolutely nothing
I think it's a way of showing positioning on a 4 dimensional axis, which is why it can be used to shoe rotation and position in 3d games
its realy nice that u explain everything unlike some other youtubers- i just hate it when they start typing with the speed of sound, say nothing abaut what they did and end the vid
The best general unity player movement tutorial on youtube!
me: types the code and follows each step carefully.
unity: 249 errors take it or leave it.
I also have such a problem. Can anyone help with that? :(
use the right case!!!!! I always use caps when i shouldn't too. Message me if you have any of those problems!
@@liftnop i have so much erors
@ASMR Darknest then put an ( ; ) there.
@@Mr-px4nz using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movement : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerbody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerbody.Rotate(Vector3.up * mouseX);
}
}
me: I will do this by myself
also me at 12 am: Brackeys tutorial fps movement
Hahahha same. I'm a noob. I can't do it without Brackeys
@@labscience8271 Im pretty good at coding, so I tried myself, but 2 days later, 7 cups of coffee drank, and a dead heart, I came to this and it worked! 😁
I love this tutorial!! I also love all the people who are helping in the comments, great video, great audience, thank you all!
Brackeys I almost quit watching you becuase I thought unity cost money but now im back and realised your my best source of knowlage.
i laughed so hard when my guy slowly started floating up into the sky
i have the same problem, can't seem to get the guy on the ground. He either shoots sideways extremely fast or floats
@@rexss90 go into your player and make sure the gravity is negative
@@nautics9927 Thanks, i figured it out finally!
@@nautics9927 THANK YOU!!
@@CrazyJoven no problem
Everyone is back here since we are all in quarantine
Hell Yeah
yup
oh yeah
after this is over we will have millions of new game developer XD
TF, i just realized i got inspired for gamemaking just because i have too much time with my laptop since the quarantine. Thank you for opening my eyes
Thank you so much Brackeys, your videos are very awesome and helpful and you explain very well what your teaching your students ♥
this tutorial is amazing. im making a game where you explore mars and find aliens and stuff but couldn't figure out how to jump, i ended up using the first part of the tutorial as a "jetpack" and calling it a day
wow
Genius
God damn it he must not live he possesses the "i will improvise" strategy.
Me acting like I understand and am not just copying everything he is doing.
"mhmmmm"
hhahhahah same
It’s weird, because the third person video’s method or script was so confusing and unknown to me but this one all makes sense?
@@sillymortalz Same XD
please help my code isnt working
if once i added the ycode for it to move p and down only that worked
it stopped looking aroud i reallycant explain
Brackeys: "And now we should be able to move around"
My Character: " *_YEET gdf bngrsdts ytnw eaygfdfgbv_* "
@DRAGO YT GAMING using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 50f;
public float gravity = -9.81f;
Vector3 velocity;
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
}
paste this in mate, see if it works. i think you might need to change a bit tho
@DRAGO YT GAMING Why do you use a capital at the start of every word?
Lolol
@@aheavyofculture C# is cap sensitive
@@user-ji3tc7ut8k so?
That's the gravy! Finally found an answer to the isGrounded issue! Great job!
This tutorial has helped me so much. Everything works perfectly
Me: Copies perfectly
Unity: 964 ERRORS
LOL
Only?
@@TKTC_The_Key Yea!. Im just good like that.
you forget the dot '-'
don't just blandly copy from it try learn and understand what he is doing so you can apply it again next time, otherwise whats the point.
When you're like, "What's wrong, nothing is showing up" but you forgot to save.
Or when you forgot to put a semicolon at the end of a line of code
@@kylu5416 or when you accidentally write code after a semicolon and leave it there in addition to a semicolon at the end
@@thespeediestgonzales7704 Or when you forgetting the multiplication dash adjacent to the vector
THAT WAS MY ISSUE THANK YOU SO MUCH
@@willgamer101dondon7 np
The video we've all needed at one point
Thank you Brackeys! I just started Unity, and these tutorials are amazing! :DD
if you finished the code and it worked, quick question: im at 9:40 in the video and im getting a few errors on line 27 (xRotation Mathf.Clamp(xRotation, -90f, 90f); ). when i save the script to unity, it tells me that ; and a , have to be placed some where, and i found where i needed to put it, but it gave even more errors. did line 27 work for you?
if it did, please tell me what i couldve done wrong
@@McCrazyDude950 uh.. My best advice here is to just restart the tutorial.
me: *watches the video 5 separate times and remembers something*
me again : *types it before brackeys says anything about it*
my brain : I am five universes ahead of you
Can anyone help me?Whenever I press spacebar the player doesnt do anything.I can move and look around though.
@@h.k654 you should check your groundcheck :d
Major parts for quick access:
00:01 - 02:49 Intro & Explanation
02:50 - 10:40 Camera Movement & Look around
10:41 - 22:50 Player Movement & Gravity
22:50 - 23:50 Outro
Thank you Brackeys
I miss you :(
Same bro :(
thanks my dude
@@Boogaloo69 same :(
hey can anyone help me please? When I added controller support my camera spins around like crazy and I don't know why
Thanks for this bro
The Fact That I Learned 3D Movement Script. YOU ARE JUST AWESOME
for whoever needs it, at 10:30, if you are having problems and your mouse is moving very little, go into Main Camera, go on the right side where it says Inspector and go down to the bottom to where it says Mouse Sensitivity and change that to 1000 or how much you are comfortable with. you're welcome
Thanks bro
@@etannn no probs
Ey bro, my cursor is still visible even tho I put the Cursor code at the start void. Do you know why?
im so sorry dude i watched this like a month ago so i have no idea lol. But ill try to find out why
@@arkilusreal its ok, actually I figure it out. Thank you very much for responding!
That terrain in the thumbnail is 10/10! Thought it was RTX Minecraft, then it started looking like a delicious cake with moss on top of it :P
Also, welcome back my dude!
Sykooooooooooooooooooo
@AlanTheGamerWolf wdym sykoo is lit
Only 3 comment
mmmm moss cake
the best level creator
Me: "ok, I copied this perfectly, it should work..."
Unity: nah, we don't do that here.
Use 2019.4 either that or your a lire
@@kanesiajones4407 r/woooosh
@@kanesiajones4407 r/woooosh
@@kanesiajones4407 r/woooosh
@@kanesiajones4407 r/woooosh
YOUR ASSETS ARE AWESOME JUST LIKE YOUR
TUTORIALS
Thanks Brackeys, really good explaining everything!
me: following every step he makes
The Word/letter color: is different
me: there's something wrong I can feel it
Could be the highlight settings. Those have probably changed in the many updates since then. Unless it's not highlighting at all, in which case you or someone has turned them off, or the code straight up doesn't work.
The way I do these tutorials is to watch them a couple of times then enter the script line by line, compiling and running as I go. He has a bewildering habit of backtracking and adding code later on which some may find instructive (not me). I wait 'til the whole script is there then enter each line and test it. Voila! No errors!
imagine A third-person game, but it's a first-person game
😒
If it in color. What happens I’m new to Unity please help me it says when I hit play remove the compiler errors.
This is the most relatable comment section I've ever seen
I agree lol
reletable :0
@@oakamaam ?
BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM BUM
Hi hi, im no
so glad they left all their videos up the gravity code helped me out big time
Mmovement:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 12f;
public float gravity = -9.81f;
public float jump = 1f;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
Vector3 velocity;
bool isGrounded;
// Update is called once per frame
void Update()
{
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
if(isGrounded && velocity.y < 0)
{
velocity.y = -2f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
if(Input.GetButtonDown("Jump") && isGrounded)
{
velocity.y = Mathf.Sqrt(jump * -2f * gravity);
}
velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
}
Mouse Look:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float MouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float MouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= MouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * MouseX);
}
}
legend
@Trupnup [GD] some heroes don't wear capes
this script makes the entire character look down not just the camera thus moving the groundcheck so you cant jump when looking down
@@Pepagg8 not important
If you wanna learn don’t copy this
If anyone is having issues with the line involving "MathF", its "Mathf" now. Hope this helps!
@nostalgia television just tryna help bro chill
That one Unity programmer that changed MathF to Mathf and earned 1000$ for it
@nostalgia television sounds like you're trying to sound smart
7:26 I love how you can learn how to not tie framerates to game speed in the first tutorial on indie development, but Bethesda couldn't do that in their fully priced, AAA title
@@speedyturtle1537 why are you spamming that everywhere
Idk... they have much bigger problems... like they aren't even using an engine comparable to unity... it's more comparable to quake ...
Its much different in Unity vs other engines, plus for larger games they generally have to create their own solutions for this anyway as a lot of unity's solutions are not perfect.
@@jamieboer3466 yeah no solution is perfect... but bethesda's cration engine is... an artefact... their previous gamebryo was so-sk back then... but gamebryo is not aimed at modern AAA
the most funny thing is, that by multiplying mouseX/Y by Time.DeltaTime actually makes sensitivity frame rate dependent, because its already done by default, so this video is wrong, you can test it by setting framerate to 10 fps and then to 1000 fps and see that sensitivy is different if you multiple by Time.DeltaTime, remove it
Brackeys you are the best game dev ever cuz u teach it to us. I am inspired by you and wanna make a game which everyone can enjoy:D
in love with your tutorials man
Brackeys tutorials will always be my go-to because his smile makes me feel welcome and ready to learn.
my camera is not rotating instead player is moving in the x axis when i move the mouse, what do i do
@@josephjohn9215 I think you meant to put this in the main video thread? I don't know how to fix your problem.
@@viola_case thank you, but someone else helped me
@@josephjohn9215 what'd they say
@@Couldbeme I didn't put the main camera in the playerlookscript in the inspector so it moved the player instead of the camera
( I think )
Me: Movement doesn't work.
Me: Looks for the error in the script.
My Brain: Everything is correct!
Me: Sees that the script isn't even enabled.
where do i pu tthe comma it wants me to put a comma WHERE IS IT AAAAAAAAAA
i've done that so much lol
Meanwhile I'm not even using a version of Unity which supports the input system used in the video.
And the video on the new input system seems to be outdated as well.
ctrl s am i joke to you
Dang, I hate when that happens
thanks brackeys you're the best for showing us that. seriously thank you
Decent tutorial to get beginners started in the right direction. However, there are at least 2 things i think you should have addressed!
1.) Trying to jump onto something can cause a stutter/jitter effect because the slope limit(it should be adjusted when you jump and then readjusted when you land)
and
2.) If an object is above the character when they jump, the character will still jump and continue to move against the object.(This would have been a good time to introduce collision flags)
EDIT: Also, the movement vector isn't normalized, resulting in an increased speed if moving at a diagonal angle.
Definitely agree that these additions would make the character controller even more solid! I didn't encounter these problems in my test scene but I can of course see cases where this would be good to add :-) Thanks for pointing this out so that people can add this to their scripts!
Could somebody please be more specific? ( I mean explain this in a more detailed way) Thanks
Hello
@@tamaskisely9122 Yeah a bit more detail would help a lot lol.
How do you normalize the movement so it takes in diagonal movement? If I just normalize the move vector3 it will cause my movement to act slidy (player still moves a bit when releasing the movement buttons)
Good tut! The physics stuff is cool and it's interesting to see how "real" physics isn't quite what we expect in games.
For those who dont seem to have the jump or the collider logic working...
Try using this logic for the ground check...
// Ground Check Logic
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask.value);
if(isGrounded && velocity.y < 0)
{
velocity.y = 0f;
}
The only change here is the addition of .value to the groundmask param in Checksphere...it did the trick for me 😊
sorry it didnt work for me
I optomized it for the new input system and it works great!
I can't believe Brackeys is gone ;_; Their content is still amazing though and they made A LOT of it
Wut happened
😭😭
I know.its sad. But I think codeMonkey still makes videos. You could check him out
I'm still crying :''''(((((
:(
Me: Gravity doesn't work.
Me: "Alright I'll continue in about 3 years,"
@Torben Kauth it worked for me
@@tinsku332Xd i can't get it to work. whenever i jump it doesn't work and turns off the gravity. any tips or code i could use?
@@jayjayjay-er9ex this should work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 12f;
public float gravity = -9.81f;
public float jumpHeight = 3f;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
Vector3 velocity;
bool isGrounded;
// Update is called once per frame
void Update()
{
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
if(isGrounded && velocity.y < 0)
{
velocity.y = -2f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
if(Input.GetButtonDown("Jump") && isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
velocity.y += gravity *Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
}
@@tinsku332Xd thank you sososososososososo much
@@tinsku332Xd i copied and pasted your code but no luck. same as before :(
Thank you so much. This helps me fine a starting point and commit to making a game
A problem that I was facing was that when I implemented the player movement script, the camera would start moving independendantly of it's parent object named "First Person Player". The reason I found for this is that in the 2020.3 and above versions of unity, the "Main Camera" comes with a script called "Simple Camera Controller (Script)". This makes the camera move within the game. You need to disable it for the camera to move with the parent object.
Edit: I found out that the problem I mentioned above only happens in URP. So if your project is not on that then you shouldn't have this problem
its only in the universal render pipeline
@@shadow501pl yeah you're right. I made the same project in HDRP and this wasn't there. I'll update my comment
Ok, but how i can disable that script?
@@paulaoag right click on the scrip and remove the component.
i dont see the component so i cant delete it
):
Me- follows instructions carefully and does everything he says
Unity- 1 error: please delete unused term “mouseY
Me- removes mouseY
Unity- 1 error: please add “mouseY
Me- *dies*
Space in btw mouse and Y?
error because the space, is "Mouse Y"
A catch 22 situation.
That happens too much.
personally it says i have to setup mouse x but i dont know how to do it
Me: sees different colours in the script on my screen than his screen
Also me:I recon this ain't workin
lol different colors dont matter
@@Charduza I am boomer, I feel embrassed
@@bigusdickus7866 I used to think that as well, don’t worry
For some reason it won't let me code do you know why that is? Do I have to download something other than unity?
@@tryfle3461 download the unity tools package for your IDE
YESSS TYSM FOR THIS, my one finally worked after try about 5 other tutorials
Thanks so much, sir! It helped me a lot in learning Unity I am a beginner so it is helpful for me and easy to understand BTW new sub 😃
Great tutorial as always! I might be wrong, but I think you are making a misstake by applying delta time to the mouse input. The reason for this is that the mouse input you are receiving is already a delta value.. It is already the amount you have moved that frame!
The mouse is an asynchronous input device. So it's position value already changes over time, not per frame!
Upvote for awareness :) Also if I'm wrong with any of my claims, please let me know for my own educational purpose.
Peace!
Thanks for the tip, it removed the stuttering for me!
@@pepijnvb1484 No problem! Glad to help :)
@@LegndGames_YT how do i do this
@@LegndGames_YT how do i do this
@@karter6632 Simply remove Time.deltaTime from the MouseLook script :)
I used this tutorial just to know how to rotate and actually make the player move, i have all the new input system stuff already with mobile joystick, and it worked!
Im glad i found this video so i could yoink your grounded detection
This is the first camera rotation script ive seen work ive sifted thru script and youtube vids for hours for this. hopefully the player movement is as easy!
It's 2021 and this video is still a GODSEND. thank you so much for not just good instructions but clear ones.
Me yesterday: Well, I'm gonna take part of a GameJam from my programming school, so I think I'll do a 3D First-Person Survival Game. *And I want to do as much as possible alone, not copying code or getting stuff from the internet*
Me after taking a look at this video: The hell are quaternions?
Me after searching about it: I'd better copy some code
Everyone copies code at first you will learn gradually over time
Haha... Explain them to me im too lazy to look them up
Most of the time u will copy code anyway. Just putting it together and make a final and unique game out of it is the difficult part. Of course u will learn over time the basics that u often use but i promise you u can't learn everything.
lol I'm working on a game with my grp and I'm at the same stuff 😂😂
Now imma copy some movements and aim codes
You don't need to know how Quaternions work to utilise their implementation. Tbh you wouldn't even need to know how they work to implement them yourself (even if it would certainly be helpful).
This genuinely helped so much fr
man i always wanted to make games and u are best teacher that i could've asked for, everything is detailed and easy to understand. i always thought that gamedev was hard but then i found u. thank a lot
2:49 video starts here (for myself, because I'll be coming back here A LOT)
Well you could export the player as a package so that you can import it into more projects in the future
thats what im trying to do rn
Thanks?
@@thunderbear06playsstuff63 How do you do that?
@@timmy21r This should be what your looking for docs.unity3d.com/Manual/AssetPackagesCreate.html hope that helps
Me: Copys his code perfectly
Unity: 341 Errors
Me: Adds 1 letter
Unity: Perfect.
fax man
me: **Forgets to put a semicolon**
Unity: This semicolon will ruin your life now.
for some reason the script for the mouselook doesn't work on my "game" what do i do?
@@lcj3_ but your IDE will point out where you missed the semi colon
@@FelineRaptor-gv4te i accidentally wrote an # in the middle of the code without even realizing and it took me 2 hours to find me that p.........
@@FelineRaptor-gv4te unity didn't even tell me where the error of the code was, it was pointing to something that i wrote correctly, when i removed the #, everything worked perfectly
Your a life saver thank you so much for all the help you are putting in for my game
noch?
@@bahaniieverett6475 n o c h
@@WextraYT nice
Thank you so much for this tutorial! it helped me a lot!
One of the most satisfying parts about coding is when you successfully debug something eventhough it was just a small error like forgetting one cast or something
Gotta say there's nothing quite as satisfying as successfully debugging; it's a mountain of negativity instantly lifted, no more errors, no more red squiggly lines, no more self doubt you don't even care that it was something really stupid, it still feels good.
couldn't have said it better
Out ranks all those satisfying video compilations on RUclips
Can anyone help me? I have a problem where I cant jump even though I copied the exact code.
@@h.k654 Did you assign the script to the player?
@@eeevoo Yes.
I used it for a 3º person game and it works just fine the only thing I changed was the camera but the rest of the movement worked smoothly, thanks so much, this helped a lot
must've been cold
@@fobman8778 what do you mean?
@@cesar3rocks783 u wrote it like 3 degrees
@@fobman8778 ooooo now I get it
@@cesar3rocks783 hahaha
This Helped me so much, you deserve a subscribe :)
“Man coding is so easy and works every time!”
-nobody on planet earth
if i hear anyone say this, i smack their face with the errors i got in the last 5 mins
I got 999+ errors in 5 minutes of coding.
@@doge7831 me to
truth :p
its actually ez and i didn't get any erro
Concise tutorial! Great for experts and beginners!
I love how the second result for 1st person movement unity is a video which doesn’t work when recreating it exactly 7 months ago, and this is from 2 years ago, simple, and works.
You're literally the best at showing us this stuff. It's a shame you don't make videos anymore...
BROOOOOOOOOOOOOOOOOOOOOOOOOOOOOO, I was sooooo hoping for a tutorial on how to make First Person Movement in Unity and am soooo glad that Brackeys made this video.
Brackeys is the BEST!!!
It would be great to have you on the team!! discord.gg/KpHx7Fj
me: copys all of the code perfectly
unity: ERROR
also me: changes from a capitalised T to an normal t
Unity: no errors
let me guess. transform and Transform?
Lmao I was seraching for answers in comments to help me you were the one I just replaced the T with a t
@@jangamer2971 bruh
I have the same problem
So in fact you DIDN'T copy the code perfectly ;)
You helped me a lot. Thanks so much!
instead of setting y and z of camera to 0, you want to set it to transform.rotation.y and transform.rotation.z in case you want to add anything that changes camera angles in the future
thanks for advise, always met this in the code, but never realized what actually it is do. cheers :)
My brain when I am a 13 year old boy and just started programming: Just copy everything and it'll work. You don't have to understand the code.
(2 seconds later) Unity: You have to fix compiled errors.
Me: Time for new project.
I'm thirteen and it's pretty simple, make sure your line of code is in between an opening and closing bracket, make sure there are no spelling errors, and maybe just learn the basics of c# like i did
same
@@salemisjuucy compiled errors
I m 12 and i get it
N M video's but it still has errors, am I using the wrong coding app? I am using c# visual studio
Just when i needed a tutorial like this, you’re a life saver!
i cant place closed brackets, how did you do it
After painful hours of looking for the problem, I figured I arranged the functions in the wrong way. Guys, always be sure you put them in the logical way.
The most helpful tutorial out there
This really helped me start 3d game development!
exactly!
i was trying to get into unity by making a simple (or so i though) character controller
turns out it was one of the hardest things to do
Don't worry.It gets harder :D
Remember Forums and documentation are your best friends and you most likely will need to merge solutions together.
Straight forward stuff in Unity will not work and need work arounds so be prepare to troubleshoot.
You can make as complex as games as you wish but you need to get your hands dirty.
@@MuttleyGames When i tried it, i could make the character move, and the camera "turn" (you know what i mean)
but i couldn't merge them together so that if the camera turned right, the character turns right
For a camera just learn to use Cinemachine.There is 0 point of using the original one.
I've made my own code and i've used people scripts...its buggy and clips trough walls.
Watch a good Cinemachine tutorial and you will save time and effort.
@@MuttleyGames Cinemachine? From looking at the pictures a few months ago i thought it was only for cinematics or cut scenes
@@lynxlagoon You can use it for that but it's a free camera you can set up in a game and it has everything you would want from a camera in terms of options and flexibility.. No coding required.
i really adore your effort to teach us...
Thanks so much! I subscibed just to how informative this is!
he quitted yt, but he has a discord, you can get help there
There’s nothing better than that feeling when you complete some code and get no errors
Ah, yes that feeling when the stars align
Sadly, for me that is a feeling I have yet to expirience
it's all cool and etc, but have you ever finally piss, after not being able to do it for several hours straight?
A worse thing is when you have no errors but it still doesn't work.
I got no errors
*Starts the game and tries to move camera*
unity: best i can do is spin