Just to let everyone know, I'm currently revamping this series in 2020, and I already have the first episode out here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-PmIPqGqp8UY.html. I strongly recommend following this instead since I've improved my methodology and included better visuals for beginners. Thanks!
Great tutorial! Although may I add that in order to prevent the player from moving faster if moving on both the x and z axis you must first normalize the vector then multiply it by the movement speed variable: Vector3 forwardMovement = transform.forward * vertInput; Vector3 rightMovement = transform.right * horizInput; Vector3 moveDir = forwardMovement + rightMovement; moveDir.Normalize(); charController.SimpleMove(moveDir * movementSpeed);
Just leaving this for any aspiring designers, but normalizing your movement vectors isn't always the right thing to do. For example the recent fps DUSK allows you to bunnyhop and move diagonally to build up massive speed and is a ton of fun once you've mastered it. Most new players will never realize this and play the game the normal "intended" way, but by not capping speed the skill ceiling of movement tech is increased exponentially for those who want to play with it.
this is literally the first tutorial that actually worked for me. Brackey's tutorial didn't work and it was super confusing, you actually explained it in a great and simple way. at least for me. thank you so much!!!!
@@katafalkistasaktyvuokwindo2739 nope he is just too fast. He write the complet script and close it if i have write 5 lines... Im try to make faster and make it faster... also the issues i make faster...and then i can look where this fcking failures are it... nice (learned my english with blueprints (2Jahrs) and Csgo... Cyka Blyad)
Very useful! I was going to go with a pre-made FPS controller at first, but then I decided I would be better off doing something like this, and I'm really happy with the results! Thanks!!
Many many thanks. I was doing Brackeys tutorial on this and i was hit with insane camera shutter. After many hours of solving and not accomplishing anything your tutorial worked wonders. No problem in editor or on build.
This is an amazing tutorial, and you did a great job both walking me through this while explaining what everything you're doing will do to the player character. Thank you.
Love your code, love the fast pace, no going over 6000 things that people at this point should know i.e. installing unity.. mad respect! looking forward to continue learning from you! this is kinda code I want! none of that makeshift shiz!
You know I actually prefer tutorials that go very fast like this. Pausing and repeating is much better than people that go way too slow. Thanks for this.
actually really really well done, do not fear to put your passion emotions into the video if you feel like it. thanks also for explaining most of the stuff
This is great! Lightweight character controller that's easy to understand and modify. I prefer this above the standard Unity character controller scripts that you can import. I especially think it's really elegant to use an animation curve as the jump force multiplier, I would've never come up with that. Thanks young Sna... Errr, Acacia!
public float walkSpeed = 10; public float runSpeed = 20; private float speed; void Start() { } void Update(){ if(Input.GetKey(KeyCode.LeftShift)) { speed = runSpeed; } else { speed = walkSpeed; } if (Input.GetKey (KeyCode.A)) { transform.Translate(Vector3.left * Time.deltaTime * speed, Space.Self); //LEFT } if (Input.GetKey (KeyCode.D)) { transform.Translate(Vector3.right * Time.deltaTime * speed, Space.Self); //RIGHT } if (Input.GetKey(KeyCode.W)) { transform.Translate(Vector3.forward * Time.deltaTime * speed, Space.Self); //FORWARD } if (Input.GetKey(KeyCode.S)) { transform.Translate(Vector3.back * Time.deltaTime * speed, Space.Self); //BACKWARD } } THIS CODE MAKES THE PLAYER AUTOMATICALLY ROTATE IN THE DIRECTION OF MOVEMENT. TO KEEP HIM FACING THE SAME WAY AT ALL TIMES, CHANGE THE " .Self " TO ".World"
same as my suggestion, except mine uses a public variable which can be changed in the inspector. i suppose you could make it a multiplier too instead of just a straight up value. and you could also put all the movement controls as public vars as well too. maybe later on when making a settings menu, with a controls sub menu, you can easily plug in the controller inputs from whatever the player chooses.
Loved it, perfect pace for someone who has never used Unity, but is a C# developer, definitely not for new coders. Wonder why the Unity devs decided to go with regular method declaration rather than overriding the inhertied class method for 'start' 'update' etc.. Simpler for new users?
Thank you very much for this great video, I like the detailed explanations and the result seems quite solid even in 2019. Still need to adapt and test a lot more but great start for me!
Sadly there are no further uploads after the 4th the channel seems abandoned, I still Subscribed though in case he comes back honestly the best tutorial I have found (No offence Brackey).
Just a tip, use Input.GetAxisRaw for the mouse so it gets the raw mouse data. On top of that, don't multiply it by Time.deltaTime. For mouse input you shouldn't do that. Because in that case the mouse will only be smooth if you have a locked FPS, which you can of course set in the game engine though generally you don't want to lock the FPS in a game since other people might have a higher refresh rate.
If you don't multiply it by deltaTime the speed of the rotation will be frame rate dependent making faster computers have a faster rotation. That's the point of multiplying by deltaTime.
Locking FPS is good, because: 1. Update() runs once each frame, so if you have more frames per second script will be run more times, so if it is an Enemy NPC that is shooting if player is close enough, then it will shoot out more bullets, because that line of code will be true more times in a second 2. If you are playing on a 60 or 30 fps and it doesn't change, then it is ok and you might not notice anything, but if FPS is changing non-stop between 30-60, then player will not only notice that, but also it will get annoying, because sometimes character reacts quickly on your controls, when sometimes it takes a little bit more which can make player die quickly. You can also search on google why some games lock their fps
Thank you very much for this tutorial. Your script is perfect for Networking with PUN 2. 6 lines and done! Players moves and rotates individualy correctly. With the Rigidbody FPS character controller from the unity standard assets... it's not that simple.
Jumping wasn't working for me either. I couldn't find a place where "JumpInput();" were called. By putting the method call in PlayerMovement(), the character started jumping
Whenever I press A or D, the engine seems to add both the vertical and the horizontal axes and the player just moves diagonally :/ I'm still learning and I just wanted to play around with the Unity engine, so, still don't know how to fix it.
would suggest rewatching the vid and paying close attention, and if that doesnt work go to the unity forums to see if theres something similar about it
Great episode I absolutely love that I found this channel, hope to see way more tutorials in the near future! Also a little question I have, I might find a solution but whatever, how do you call the co-routine while still being able to move around? Thanks in advance :D
Can you add make a tutorial on mid-air movement? I noticed that simple move returns if non-grounded and move in both coroutine and update doesn't work.
When I save the script and go back to Unity, on the Camera game object, in the script component the Sensitivity, MouseX and MouseY doesn't show up! Please help me fix it!
I know this is an older series, but I implemented this jump script with the newer movement script that you've posted and it works, but I find that my jump key doesn't register ever single time, but rather every 2 or 3 presses unless I get lucky and I can jump muliple times in a row without fail. Any idea what could be causing this bug?
This is such a good video dude. You explain what you are doing with little slides, it's so much better than a normal tutorial video on youtube. I feel like I'm learning stuff here rather than just doing what they do on screen. My only complaint is that you maybe go a little too fast when actually typing the code.
If you start falling off the edge of something and press space, you can still jump. To fix this you should initially check if the character is grounded before allowing a jump.
This is the most helpful FPS controller tutorial for Unity I've come across so far. I realize this video is almost two years old, but I've heard you don't want to use Time.deltaTime when dealing with mouse movement because the mouse is an asynchronous input device (i.e., its position changes over time, not per frame). Is that right?
Hey, great video. :) Question, though. Why separate the movement and look scripts? Why not have the functionality of both on the same script? Is there a downside to putting them both in one? Thanks!
I appreciate how you explain things both clearly and quickly. So many RU-vid tutorials take 2 minutes of introduction and then split each individual element into a separate video when the information could fit into a video around this size. Anyway, really excellent, I learned a lot.
This has been an awesome series and I have followed through till the end except I can't figure out one thing! If you wanted to move left and right/turn around mid air, how could you go about this?
Thanks for the tutorial, controller works great, only gripe is about your work flow speed, im getting fairly good at coding in C# but found it hard keeping up with what you were doing and why.
great video, but I have one problem. Whenever I create a variable, specifically [SerializeField] private Transform playerBody; on time 9:45, it doesn't show up in the inspector under PlayerCamera. Any ideas?
Thanks! Great video! I have one issue though, when my character jumps and hits a ceiling, he keeps floating instead of dropping straight down, he only goes down after the jump doesn't have anymore force, i dont know whats wrong. Please help
I just had the same issue. In the PlayerMove script between the lines "timeInAir~" and "yield return null" add: if ((charController.collisionFlags & CollisionFlags.Above) != 0) { break; } The while loop should be catching the collisions from above, but doesn't for some reason. My implementation probably isn't the best, but it seems to work.
how would i add " , Space.Self" to this script?? My player rotates in different orientations for special powerups, but i want the direction to remain the same no matter how he is rotated.
For some reason after typing the first of the mouse look script, I don’t have the extra options in the player look script in player camera. Am I doing something incorrect?
I don't understand very good your question but if you want to know how you can see again your mouse you can put this: Cursor.lockState = CursorLockMode.None
Pops up and such an error in the code Assets / PoruszanieKamera / PlayerLook.cs (4,7): error CS0246: The type or namespace name `UnityCursor 'could not be found. Are you missing an assembly reference? how can I fix it and I'm new so I don't know you so well ;)
Fantastic tutorial, but I am having one issue: The movement of the player works fine, but when I'm using the camera, it seemingly randomly jitters, skipping some movement, moving much faster for like a millisecond. I'm not sure what's causing this, so some advice would be amazing.
Make sure you didn’t put the camera movement into fixedupdate, always make sure input is done in update. I think that’s what you need to do anyway I’m still new too so yeah.
because public means other classes can see and modify it, with a benefit of being able to see and modify it in the inspector. However serialize field means you can see and modify in the inspector exclusively and other classes cant see or modify it. I am unsure but this possibly improves performance and increases security of the variables and lowers the chance of them being tampered with. Hope that helped :D
@@Glentgm And that's just best practice. You shouldn't allow access to anything that doesn't need it. So make it private serialized unless you have to make it public.
Notice how the op said " how and why", the "why" being an important part of the comment. Simply slowing the video down will not explain the " why" for the those seeking more in depth explanations; it just provides for them, what they consider to be, complicated concepts at a slower speed.
Update isn't exact, it's locked to frame rate. So if you rotate the Camera fast enough, the Camera will overshoot the bound but your clamp value will be clamped. So it will slightly offset your rotation range everytime. Do it enough times and you can flick the camera around.
This is great thanks, I've discovered one weird bug, if I move sideways I can jump, but if I run forward or back I can't. I think this might have something to do with the slopeForce? Any ideas?