This is the best coding tutorial I have gotten so far. When I first tried Unity, I was unable to comprehend the game engine and quit. Now, a few months later, I have a working 3D project. Thank you. So much.
Bro I fucking love you. I had spent half an hour battling with like 3 scripts for the alternative input manager from unity until I decided to scrap the entire movement system and look for another solution. Yours worked like a charm, you are a legend man
Issue: -Player falls through the ground even with colliders (on plain / terrain; and on player model) Fix: - If you create a player folder as in the video, you must nest the camera under the player model I've also chatGPT'd the script. (Sorry, I suck at writing code, I learn by being shown examples) This version has a crouch transition (and moves it from "R" to Left Control (Bro wtf, why u crouch on R?) Also, it has some more fine tuning to make it feel more real (or closer to CS / Source Games) It also prevents the running speed to apply mid air; Cant run while crouched; Run Speed is maintained if you release shift mid air. (couldn't figure out to keep the momentum if you release any of the walk keys, sorry) Added a crouch speed option. Slow tbag / Fast tbag. using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(CharacterController))] public class PlayerMovement : MonoBehaviour { public Camera playerCamera; public float walkSpeed = 3f; public float runSpeed = 6f; public float jumpPower = 7f; public float gravity = 20f; public float lookSpeed = 2f; public float lookXLimit = 90f; public float defaultHeight = 2f; public float crouchHeight = 1f; public float crouchSpeed = 3f; public float crouchTransitionSpeed = 15f; // Speed of crouch height transition private Vector3 moveDirection = Vector3.zero; private float rotationX = 0; private CharacterController characterController; private bool canMove = true; private bool isCurrentlyRunning = false; // Tracks running status private float targetHeight; // Target height for crouching/standing void Start() { characterController = GetComponent(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; // Set initial height targetHeight = defaultHeight; } void Update() { Vector3 forward = transform.TransformDirection(Vector3.forward); Vector3 right = transform.TransformDirection(Vector3.right); // Determine if the player is grounded bool isGrounded = characterController.isGrounded; // Crouch logic (press and hold) if (Input.GetKey(KeyCode.LeftControl) && canMove) { targetHeight = crouchHeight; } else { targetHeight = defaultHeight; } // Smoothly adjust height characterController.height = Mathf.Lerp(characterController.height, targetHeight, crouchTransitionSpeed * Time.deltaTime); // Adjust speed while crouching bool isCrouching = Mathf.Abs(characterController.height - crouchHeight) < 0.1f; if (isCrouching) { isCurrentlyRunning = false; // Cannot run while crouching } // Determine movement speed if (Input.GetKey(KeyCode.LeftShift) && isGrounded && !isCrouching) { isCurrentlyRunning = true; // Start running if grounded and shift is held } else if (isGrounded) { isCurrentlyRunning = false; // Stop running if grounded and shift is not held } float currentSpeed = isCrouching ? crouchSpeed : (isCurrentlyRunning ? runSpeed : walkSpeed); float curSpeedX = canMove ? currentSpeed * Input.GetAxis("Vertical") : 0; float curSpeedY = canMove ? currentSpeed * Input.GetAxis("Horizontal") : 0; // Preserve Y-axis movement float movementDirectionY = moveDirection.y; if (isGrounded) { // Update movement direction when grounded moveDirection = (forward * curSpeedX) + (right * curSpeedY); } else { // Maintain momentum while airborne Vector3 horizontalVelocity = new Vector3(moveDirection.x, 0, moveDirection.z); Vector3 inputVelocity = (forward * curSpeedX) + (right * curSpeedY); // Add input to current horizontal velocity if (inputVelocity != Vector3.zero) { horizontalVelocity = inputVelocity; } moveDirection = horizontalVelocity; } // Apply Y-axis movement moveDirection.y = movementDirectionY; // Jump logic if (Input.GetButton("Jump") && canMove && isGrounded) { moveDirection.y = jumpPower; } // Apply gravity if not grounded if (!isGrounded) { moveDirection.y -= gravity * Time.deltaTime; } // Move the character characterController.Move(moveDirection * Time.deltaTime); // Handle camera rotation if (canMove) { rotationX += -Input.GetAxis("Mouse Y") * lookSpeed; rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit); playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0); transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0); } } }
holyyyyy this is the tutorial that was the easiest to understand. also thank you so much for posting the code in the comments, I don't have to pause the video every 10 seconds to write the code and waste time. Instead i can look through it myself after it is in a working state.
I will literally make out with you u finally helped all the ppl who needed this perfect script without any fking errors I've been struggling with other scripts for days and your's work. Thank you so much!
for some reason i have a bug, my player is moving without control, if you make a vid of how to fix that than you will get 10 subs (because i have this and other 9 devices)
If your player is falling then click the player folder and a green line will show up. Click the capsule and move it up to the green line and it should work!
It works, to explain further it can be fixed under the "transform" component by setting the "camera" and "player" component to 0 on all the axes and when you want to move the player you should move the player folder because the items in the folder are relative to the player folders position
Hay I know you posted this 2 months ago but I’m having a bit of trouble because when I add the script as a component it doesn’t add the character controller and the script shows but has no variables like “Camera” and “walk speed” it only has the name of the script.
ur such a W bro, ive been looking for wasd controls since like, january, and this one finally worked, and i didnt expect it to only take 2 minutes, (i know it wouldve taken way longer if you didnt just let us copy the code, and instead walked us through the code like others)
Bro I tried to like make this by myself but for some reason my dumb ahh brain could not because I tried rigidbody which made the movement super unnatural but with your script, and character controller, it is very effective and super natural movement. Thanks bro and you just earned a free sub and a like.
Bro thanks so much I watched a lot of other videos and I made it for so long but it didn’t even work but thanks to you you even put the script in the commans
I might be wrong but the walk speed doesn't seem to be set correctly. You are setting the walk speed to the crouch speed when the crouch button is selected, else you are setting the walk speed to 6f directly. So while the variable is technically public, it is set automatically by that function. A solution I found was to create an "originalWalkSpeed" variable that is set the same as walk speed. So instead of saying walkSpeed = 6f, you would say walkSpeed = originalWalkSpeed;. Keep in mind that I removed the sprint functionality so it could have been a result of that, but I don't think so.
Can you please help me ive been trying for ages and ive restarted the project loads of times but nothing works. At 1:40 when i drag and srop it there is no option for the player camrea and its just all greyed out please help ive looked at multiple videos but its just the same issue.
Everything worked fine except the fact that My character decided just not to obey the laws of physics and follow through the ground so EDIT THANK YOU FOR 38 LIKES
For me it falls through the terrain even tho i have colliders for both they are not trigger (Fixed it i deleted the empty gameobject called player then i added the script to my player (game object)) (Fixed it)
uh everytime i try to drag the player movement script into the player 1:40 it writes this: Can't add script behaviour 'PlayerMovement'. The script needs to derive from MonoBehaviour! pls help
hmm try to make another script with camera movement and delete the camera movement from the movement script and like just make a new one or search up a new script
thanks for not putting a 1 minute intro, 2 minute explanation on what the script does, 1 minute of trying to fix a bug in the script, and 5 minutes of blabbering but instead just going into the video instantly
the camera didnt follow the player model and when i look around it looks at the middle of something; basically when i look around it moves my player in a giant circle
can someone help my floor keeps falling into the void and i can't find a tutorial to fix it i only started unity yesterday and if u can help the will me appreciated
Can't add script component 'PlayerMovement' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
it did work but For me I was not impressed I started to have problem like the camera not sticking to the player and even with colliders for my ground it still falls thought but kinda helpfull
why does it only permit monobehaviour scripts?i cant add the script component on empty c script,i cant even make games with that,what did unity did dude...
not only did this man make a 2 min tutorial straight to the point, but even put the script in the comments. Absolute chad. Keep up the great work. However im having a small problem. When i change the values of the Run speed & walk speed and then start the game the run speed resets to 12 and the walk speed resets to 6. How can i fix this?
Did you make sure that you edited the values with the play button unselected? If you change anything while in play mode (even if you also have it paused) it will reset.
Sorry for the late reply, instead of through unity, try changing the values through the actual script. Just look for where I have the walk and run speed set and change the values there. You can use control f to search for keywords.
Hey thank you! I used your code for my game to make snappy movement and its perfectly scalable and clean! I have some big ideas and needed a good movement base to work off of so thank you so much
First of all, THANK YOU SO MUCH. Besides this, could you please create more videos similar to this one? It's helped me a lot, and it would be great if you could help with other things as well
I've got a question, though I'm not sure if you'll answer given this is a 9 month old tutorial. The movement works overall, but I find that when moving diagonally the speed is increased. Do you have any idea on how to fix this?
i had 3 errors while adding your script and i dont know how to fix them pls could u tell me how to the errors were Assets/PlayerMovement.cs(23,10: error CS1529: A clause must precede all other elements defined in the namespace exept extern allies declarations
actually, creating a folder named player causes some problems as the player is falling through the terrain. instead of doing that, do the same things without creating player folder. just a capsule and a main camera.
Here is the script. If you are confused please let me know!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class PlayerMovement : MonoBehaviour
{
public Camera playerCamera;
public float walkSpeed = 6f;
public float runSpeed = 12f;
public float jumpPower = 7f;
public float gravity = 10f;
public float lookSpeed = 2f;
public float lookXLimit = 45f;
public float defaultHeight = 2f;
public float crouchHeight = 1f;
public float crouchSpeed = 3f;
private Vector3 moveDirection = Vector3.zero;
private float rotationX = 0;
private CharacterController characterController;
private bool canMove = true;
void Start()
{
characterController = GetComponent();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
Vector3 right = transform.TransformDirection(Vector3.right);
bool isRunning = Input.GetKey(KeyCode.LeftShift);
float curSpeedX = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Vertical") : 0;
float curSpeedY = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Horizontal") : 0;
float movementDirectionY = moveDirection.y;
moveDirection = (forward * curSpeedX) + (right * curSpeedY);
if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
{
moveDirection.y = jumpPower;
}
else
{
moveDirection.y = movementDirectionY;
}
if (!characterController.isGrounded)
{
moveDirection.y -= gravity * Time.deltaTime;
}
if (Input.GetKey(KeyCode.R) && canMove)
{
characterController.height = crouchHeight;
walkSpeed = crouchSpeed;
runSpeed = crouchSpeed;
}
else
{
characterController.height = defaultHeight;
walkSpeed = 6f;
runSpeed = 12f;
}
characterController.Move(moveDirection * Time.deltaTime);
if (canMove)
{
rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
}
}
}
baller
THANK YOU!!!
❤🎉
ConsoIe says playerCamera is not defined
Wait nevermind
bro you are my hero. i have been stuck at the player movement for 4 years but finally i found a working tutorial. i love you so much
No problem!
This is the best coding tutorial I have gotten so far. When I first tried Unity, I was unable to comprehend the game engine and quit. Now, a few months later, I have a working 3D project. Thank you. So much.
You're very welcome!
@@Brogrammer1 Make an explanation video
I would like A kind of detailed tutorial that shows you how to like change the speed and jump height I like something like that
just change them in the script
@@pengloalt5 fr
also @pengloalt5 its nice to see some people stilll coding and watching this channel
finally no garbage tutorial 2h long where I will forget stuff 3 seconds after doing them. straight to the point. thanks :D
Bro I fucking love you. I had spent half an hour battling with like 3 scripts for the alternative input manager from unity until I decided to scrap the entire movement system and look for another solution. Yours worked like a charm, you are a legend man
Same
Glad I could help :)
Issue:
-Player falls through the ground even with colliders (on plain / terrain; and on player model)
Fix:
- If you create a player folder as in the video, you must nest the camera under the player model
I've also chatGPT'd the script. (Sorry, I suck at writing code, I learn by being shown examples)
This version has a crouch transition (and moves it from "R" to Left Control (Bro wtf, why u crouch on R?)
Also, it has some more fine tuning to make it feel more real (or closer to CS / Source Games)
It also prevents the running speed to apply mid air; Cant run while crouched; Run Speed is maintained if you release shift mid air. (couldn't figure out to keep the momentum if you release any of the walk keys, sorry)
Added a crouch speed option. Slow tbag / Fast tbag.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class PlayerMovement : MonoBehaviour
{
public Camera playerCamera;
public float walkSpeed = 3f;
public float runSpeed = 6f;
public float jumpPower = 7f;
public float gravity = 20f;
public float lookSpeed = 2f;
public float lookXLimit = 90f;
public float defaultHeight = 2f;
public float crouchHeight = 1f;
public float crouchSpeed = 3f;
public float crouchTransitionSpeed = 15f; // Speed of crouch height transition
private Vector3 moveDirection = Vector3.zero;
private float rotationX = 0;
private CharacterController characterController;
private bool canMove = true;
private bool isCurrentlyRunning = false; // Tracks running status
private float targetHeight; // Target height for crouching/standing
void Start()
{
characterController = GetComponent();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
// Set initial height
targetHeight = defaultHeight;
}
void Update()
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
Vector3 right = transform.TransformDirection(Vector3.right);
// Determine if the player is grounded
bool isGrounded = characterController.isGrounded;
// Crouch logic (press and hold)
if (Input.GetKey(KeyCode.LeftControl) && canMove)
{
targetHeight = crouchHeight;
}
else
{
targetHeight = defaultHeight;
}
// Smoothly adjust height
characterController.height = Mathf.Lerp(characterController.height, targetHeight, crouchTransitionSpeed * Time.deltaTime);
// Adjust speed while crouching
bool isCrouching = Mathf.Abs(characterController.height - crouchHeight) < 0.1f;
if (isCrouching)
{
isCurrentlyRunning = false; // Cannot run while crouching
}
// Determine movement speed
if (Input.GetKey(KeyCode.LeftShift) && isGrounded && !isCrouching)
{
isCurrentlyRunning = true; // Start running if grounded and shift is held
}
else if (isGrounded)
{
isCurrentlyRunning = false; // Stop running if grounded and shift is not held
}
float currentSpeed = isCrouching ? crouchSpeed : (isCurrentlyRunning ? runSpeed : walkSpeed);
float curSpeedX = canMove ? currentSpeed * Input.GetAxis("Vertical") : 0;
float curSpeedY = canMove ? currentSpeed * Input.GetAxis("Horizontal") : 0;
// Preserve Y-axis movement
float movementDirectionY = moveDirection.y;
if (isGrounded)
{
// Update movement direction when grounded
moveDirection = (forward * curSpeedX) + (right * curSpeedY);
}
else
{
// Maintain momentum while airborne
Vector3 horizontalVelocity = new Vector3(moveDirection.x, 0, moveDirection.z);
Vector3 inputVelocity = (forward * curSpeedX) + (right * curSpeedY);
// Add input to current horizontal velocity
if (inputVelocity != Vector3.zero)
{
horizontalVelocity = inputVelocity;
}
moveDirection = horizontalVelocity;
}
// Apply Y-axis movement
moveDirection.y = movementDirectionY;
// Jump logic
if (Input.GetButton("Jump") && canMove && isGrounded)
{
moveDirection.y = jumpPower;
}
// Apply gravity if not grounded
if (!isGrounded)
{
moveDirection.y -= gravity * Time.deltaTime;
}
// Move the character
characterController.Move(moveDirection * Time.deltaTime);
// Handle camera rotation
if (canMove)
{
rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
}
}
}
hey i did it and its not fixed. what can i do?
THANK YOU BRO IM GIFTING U A SUB DUDE THANK YOU!!! THIS HELPED ALOT❤❤
This was really helpful, I couldn’t find a tutorial that I actually understood until now
Glad I could help
@@Brogrammer1 You earned a sub Thanks
It doesn’t work 😢
@@GKBGAMER9733 It does
if we just copy the code, that not mean we understand it
...
I tried for SOOO Long to look for a good Tutorial, YOU ARE THE GOAT THANKS MAN!!!!
hey, i wanted to thank you. i needed this for a schoolproject i need to finish next week. thanks
A bit late, but im glad I could help :)
holyyyyy this is the tutorial that was the easiest to understand. also thank you so much for posting the code in the comments, I don't have to pause the video every 10 seconds to write the code and waste time. Instead i can look through it myself after it is in a working state.
I like to make my videos as easy as possible to follow :) glad I could help
I HAVE BEEN SEARCHING THROUGH SO MANY TUTORIALS AND UR IS THE FIRST TO ACTUALLY WOKR!!!!!!
I'm glad to hear it worked :)
GOD BLESS YOU!!!!! I SPENT 5 HOURS TRYING TO DO IT N HERE YOU ARE DOING IT IN 2 MINUTES
Thanks man! This saved me a good amount of time as a beginner game designer. Much appreciated.
I will literally make out with you u finally helped all the ppl who needed this perfect script without any fking errors I've been struggling with other scripts for days and your's work. Thank you so much!
for some reason i have a bug, my player is moving without control, if you make a vid of how to fix that than you will get 10 subs (because i have this and other 9 devices)
Bro Your A Frickin LIFESAVER man, THANKS
No Problem!
bro thank you so much i wouldve never been able to do anything ever and wouldve deleted unity immediately if i didnt have this
If your player is falling then click the player folder and a green line will show up. Click the capsule and move it up to the green line and it should work!
It works, to explain further it can be fixed under the "transform" component by setting the "camera" and "player" component to 0 on all the axes and when you want to move the player you should move the player folder because the items in the folder are relative to the player folders position
Hay I know you posted this 2 months ago but I’m having a bit of trouble because when I add the script as a component it doesn’t add the character controller and the script shows but has no variables like “Camera” and “walk speed” it only has the name of the script.
same
Same
Sorry for the super late reply - Make sure the name of the script is the exact same as the one I used in the video. That could be the issue.
Ok because I’m having the same issue
@@Chris-Stikman I fixed the issue, you kinda just have to re-save the script until it works
Thanks bro finally after 2 days I got a perfect tutorial love from india🇮🇳🇮🇳🇮🇳
I love you, you are the best, YOU PUT THE SCRIPT DOWN, THE SCRIPT WORKS PERFECTLY, YOU SOLVED A 5 HOUR LONG PROBLEM IN SECONDS, YOU NEED ALL THE SUBS
FRRR
Bro absolute best tutorial i've ever used!
ur such a W bro, ive been looking for wasd controls since like, january, and this one finally worked, and i didnt expect it to only take 2 minutes, (i know it wouldve taken way longer if you didnt just let us copy the code, and instead walked us through the code like others)
i have been using this tutorial for like a year and it still works thank you!!!
bro how? i used it and it says assets\PlayerMovement\.cs(97,6):error CS1002 : ; expected
best tutorial i have ever seen thanks very much bro
i subed and liked
Thank you!, One of the best controllers i've seen so far the others are either inverted controlls or just fall over
Learning the basics and watched many videos and this worked perfectly thank you!!
First totorial that works. Thank you
No Problem!
Thank You so much this showed exactly what to do. You earned a sub!
Bro I tried to like make this by myself but for some reason my dumb ahh brain could not because I tried rigidbody which made the movement super unnatural but with your script, and character controller, it is very effective and super natural movement. Thanks bro and you just earned a free sub and a like.
EEK!! THANK YOU SO MUCH BRO, I LOVE YOU!! (not in a weird way)
Thank you so much, I am just getting started with unity and this tutorial is helping me create my dream game!!!!
THANK U SO MUCH MAN THIS IS MY LIKE 20TH TUTORIAL THAT I TRIED AND IT FINALLY WORKS THANKS
Haha, glad I could help!
Thanks for this! Worked completely fine.
does not work when I put the script on the player it does not show any thing to attach my camera too
Damn, third time realy is the charm, tried 2 before, both failed, and now i see a realy simple fast tutorial, and it works like a charm
Thanks for the help because I'm new to unity :)
You're welcome :)
thank you, Ive been serching for hours how to make my player move and youre tutorial was the only on that worked, thank you
Glad I could help!
Thanks! So many tutorials but this one was the best!
HI
HOW TO TURN THE CAMERA SIDEWAYS
Thank you so much! This worked amazing and helped a lot!
Bro thanks so much I watched a lot of other videos and I made it for so long but it didn’t even work but thanks to you you even put the script in the commans
this is the PERFECT Tutorial its short and everything works perfect this is the first game i ever make and im so happy thx a lot
hippity hoppity, this code is my property (this tut actually helped a lot thanks mate)
No problem :)
Finally a tutorial that works i love you bro keep up the good work.
Easiest and fastest fps view game controller thankyou so much.
This is a really good video it helped me
this was actually helpful thanks
bro thank you so much this really helped me
Glad it helped
I loved the video and it really helped me a lot! Thanks!
Glad it helped!
I might be wrong but the walk speed doesn't seem to be set correctly. You are setting the walk speed to the crouch speed when the crouch button is selected, else you are setting the walk speed to 6f directly. So while the variable is technically public, it is set automatically by that function. A solution I found was to create an "originalWalkSpeed" variable that is set the same as walk speed. So instead of saying walkSpeed = 6f, you would say walkSpeed = originalWalkSpeed;.
Keep in mind that I removed the sprint functionality so it could have been a result of that, but I don't think so.
Thanks so much for script, you just write my 1st script
I would suggest putting a collider on the camera so that you do not see through things
Can someone pls help when ever i try to drag the script into the conponent box it says the file name and class name dont match
Really great tutorial! I can finaly start making stuff!
Great to hear!
bro thanks so much it works perfectly and it is sick and easy bro keep the good work up
Happy to hear it works :)
Can you please help me ive been trying for ages and ive restarted the project loads of times but nothing works. At 1:40 when i drag and srop it there is no option for the player camrea and its just all greyed out please help ive looked at multiple videos but its just the same issue.
nvm i got it working
@@Ruarc1how did you fix it
@@Ruarc1 thats happening to me how did you fix it?
@@Hydrix_1 me too its so annoying
How did you fix it I'm having the same problem
Very good Tutorial easy to setup so customizable I subscribed btw :)
Thanks for the sub! I'm glad it works
Thank you so Fuuuuging much bro easies tuturial ever
Thank u very much for this great tutorial :D
Thank you so much! Worked like a charm!
thank you this was super useful :)
Glad it was helpful!
thank you brother i was struggling tryna learn the code but u made it so easy great to help me study and referance off of big thanks
Thats literally the best video tutorial about fps control
Glad you liked it :) More videos coming up as well
It says it can’t add the script but that’s probably because I’m on the wrong version of unity
Everything worked fine except the fact that My character decided just not to obey the laws of physics and follow through the ground so EDIT THANK YOU FOR 38 LIKES
Add a rigidbody component to it. Should work fine
Cause you didn't add a capsule collider to it or maybe you didn't add a collider to your ground
Fr
😂
Mine some reason floats
For me it falls through the terrain even tho i have colliders for both they are not trigger (Fixed it i deleted the empty gameobject called player then i added the script to my player (game object)) (Fixed it)
Glad it hear its working now 👍
uh everytime i try to drag the player movement script into the player 1:40 it writes this:
Can't add script behaviour 'PlayerMovement'. The script needs to derive from MonoBehaviour!
pls help
Can't add script behaviour 'PlayerMovement'. The script needs to derive from MonoBehaviour!
I tried third person but the camera keeps on turning around when i start up the game and wont follow the player
hmm try to make another script with camera movement and delete the camera movement from the movement script and like just make a new one or search up a new script
thanks for not putting a 1 minute intro, 2 minute explanation on what the script does, 1 minute of trying to fix a bug in the script, and 5 minutes of blabbering but instead just going into the video instantly
the camera didnt follow the player model and when i look around it looks at the middle of something; basically when i look around it moves my player in a giant circle
can someone help my floor keeps falling into the void and i can't find a tutorial to fix it i only started unity yesterday and if u can help the will me appreciated
I think that the floor doesn’t have collision
Idk how to add collision i just got unity today
add mesh collider to floor
you are a LIFE SAVER!!! i was so confused since i dont know c#, thank you a lot!
Bro im totally new to unity and this tutorial will help me with alot of games
Can't add script component 'PlayerMovement' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.
it did work but For me I was not impressed I started to have problem like the camera not sticking to the player and even with colliders for my ground it still falls thought but kinda helpfull
why does it only permit monobehaviour scripts?i cant add the script component on empty c script,i cant even make games with that,what did unity did dude...
Hey I'm a bit confused here I made an entire character model inside of unity And Do I have to scrap it for the Capsule or can I use this
the capsule is simply a placeholder
Thanks for pinning the script in comments❤❤
not only did this man make a 2 min tutorial straight to the point, but even put the script in the comments. Absolute chad. Keep up the great work. However im having a small problem. When i change the values of the Run speed & walk speed and then start the game the run speed resets to 12 and the walk speed resets to 6. How can i fix this?
Did you make sure that you edited the values with the play button unselected? If you change anything while in play mode (even if you also have it paused) it will reset.
Edit the code on lines 67 and 68. It says that if you are not crouching or sprinting, it will set these values to 6 and 12
Sorry for the late reply, instead of through unity, try changing the values through the actual script. Just look for where I have the walk and run speed set and change the values there. You can use control f to search for keywords.
Hey thank you! I used your code for my game to make snappy movement and its perfectly scalable and clean! I have some big ideas and needed a good movement base to work off of so thank you so much
Great..finally I got it to work..thanks
Thanks man this was a lot of help❤
VERY helpful and simple! Thank You for nailing this tutorial!
First of all, THANK YOU SO MUCH. Besides this, could you please create more videos similar to this one? It's helped me a lot, and it would be great if you could help with other things as well
FINALLY, THANK YOU MAN YOU SAVED MY LIFE
HI
HOW TO TURN THE CAMERA SIDEWAYS
No problem!
I've got a question, though I'm not sure if you'll answer given this is a 9 month old tutorial. The movement works overall, but I find that when moving diagonally the speed is increased. Do you have any idea on how to fix this?
don't fix it, it's a really known thing on movement systems, games like minecraft and karlson have it. it is not uncommon at all
@@gokete3555 Thing is, i don’t really want that in my game
@@TMP5_xd no one will notice that
@@Dylanj8795 They almost certainly will
@@TMP5_xd I have been playing games for a really long time now and I have never noticed that so….
Finally i don't have to sit here for 30 miinutes to make movement. Chad
No wasted time here👌
Great Brother ! .i was Looking For the Perfect Movement Script ,!
Glad it works :)
i had 3 errors while adding your script and i dont know how to fix them pls could u tell me how to the errors were Assets/PlayerMovement.cs(23,10: error CS1529: A clause must precede all other elements defined in the namespace exept extern allies declarations
the other 2 were the same (errors)
Ensure that the name of the file is the exact name I used in the video! Also copy the code directly from the comments and use that.
Thanks! This tutorial was really helpfull for my game.
Great!
@@Brogrammer1 i can't rotate :(
can you help me?
Hi
HOW TO TURN THE CAMERA SIDEWAYS@@Brogrammer1
when i play the game my bean player starts spinning around and then falls down
op bro good job and pls make the video how to make AI enemies in your game in unity
Sorry for the late response. I will work on that video soon! I just upload a working gun, so that could get you started on your ai journey :)
@@Brogrammer1 thanks bro for the Gun tutorial its really helpful
Support from India
my camera is sucessfully moving but my player character wont move an inch no matter what i do. anyone know the fix?
actually, creating a folder named player causes some problems as the player is falling through the terrain. instead of doing that, do the same things without creating player folder. just a capsule and a main camera.
This worked for me. Thanks!
great video man 👍
Appreciate it!
When I double click on the script it asks me "How do you want to open this file" and I'm just wondering what file do I choose to open the script.
Bro thank you, you helped so much!!!!
Thank you very much it work really good for my