FPS Full Game Tutorial | Unity | Part 1 - Basic Movement

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ธ.ค. 2024

ความคิดเห็น • 219

  • @juniorbessing
    @juniorbessing ปีที่แล้ว +18

    I'm excited about this new series, I signed up for the survival series, I'm also going to follow this one!!

  • @meth2326
    @meth2326 7 หลายเดือนก่อน +36

    I have seen a lot of people struggling over the player not being able to jump while looking down or having their player model rotate with the camera, i had the same exact issue. So after a little bit of trial and error i came up with this solution:
    You need to go to the part where it says:
    Vector3 move = transform.right * x + transform.forward * z;
    Replace that line for this
    Vector3 move = Camera.transform.right * x + Camera.transform.forward * z;
    And at the start of the code add this:
    public transform Camera;
    Then go to the player inspector, go to the script part and drag the camera in the transform section similar to groundcheck
    Finally, grab the Mouse script, remove it from the player and add it to the camera object
    I hope this works for all of you and try to make this comment get to the top so more people can see it, love from Argentina
    Check replies if it doesnt work

    • @shrenikmunot9897
      @shrenikmunot9897 7 หลายเดือนก่อน

      Unfortunately , it still does not work , do you have any other solutions ?

    • @rambdube
      @rambdube 6 หลายเดือนก่อน +2

      @@shrenikmunot9897 how about adding a head to the body and applying the rotating transforms only on the head so the body(and ground check object) won't tilt and cause problems with the jumping...

    • @meth2326
      @meth2326 6 หลายเดือนก่อน +1

      @@rambdube A little while after commenting this i kind of did that, what i did was create an empty game object named "orientation" and placing it at the head of the body. Then modified the player code again to say the following:
      Vector3 move = Orientation.transform.right * x + Orientation.transform.forward * z;
      Then i created a new script named orientation. I copied the camera script on to it, BUT, removed the part that allowed it to move vertically, so the camera and the orientation are alligned in the X axis, but not on the Y axis, this way, if you look up or down you still move forward and not fly into the air or move slower.
      Also, you will need to add this
      public transform Orientation;
      Go to player inspector, script variables, and drag the orientation game object. Then just add the orientation script to the orientation object

    • @tohiroGm
      @tohiroGm 4 หลายเดือนก่อน

      @@meth2326 не работает(

    • @Rip-y3u
      @Rip-y3u 2 หลายเดือนก่อน

      Thanks

  • @Youuzzi
    @Youuzzi หลายเดือนก่อน +3

    For those who cannot move and jump, you must change the height of your console character, and make sure your foundation is not too far from your body so that the system can read it correctly, not too low or too high, and for ground checks it must also be in accordance with the ideal number.

  • @Dimitri_gaming843
    @Dimitri_gaming843 3 หลายเดือนก่อน +3

    Im here again , this time i watch this series again, to understand the code, next time please be a bit slowly, but anyway, you make the best tutorial ever exist on youtube!

  • @iHelpFul
    @iHelpFul ปีที่แล้ว +2

    I waited for this series alsoooo, i finish(till now) the survival game tutorial and im also going to follow this one, cant wait for the learning !!!!!

  • @midiolympics5105
    @midiolympics5105 ปีที่แล้ว +3

    So stoked for this series!

  • @MattisDeveloper
    @MattisDeveloper ปีที่แล้ว +1

    Hello :) Excited to start this series :)

  • @devanmauch7843
    @devanmauch7843 29 วันที่ผ่านมา

    This is awesome, working on my first shooter and excited to continue!

  • @pallacron
    @pallacron หลายเดือนก่อน

    Love your tutorials man, you're a good teacher! I'm just going through them all so I can learn more
    If anyone is using Unity 2022.3.16f1 and their for Mouse Rotation isn't working - my VS/Unity combo doesn't like negative defaults for some reason - so when you change the topClamp to -90 in your IDE/Script Editor, check the Inspector mine still said 90, this isn't the first time I've seen this

  • @D0s3_Gaming
    @D0s3_Gaming ปีที่แล้ว +7

    Found something interesting. You can't jump while looking down. Probably because the camera controller is connected to the whole player and not just the camera so the ground check leaves the ground when u look up or down but idk. I'm no coder.

    • @meth2326
      @meth2326 7 หลายเดือนก่อน +8

      you are right, the whole thing rotates down and up. This is also inconvenient for enemy encounters, since the player can look up or down to dodge bullets or attacks because the hitbox of the player is connected to it
      Edit: I just found the solution. You need to go to the part where it says:
      Vector3 move = transform.right * x + transform.forward * z;
      Replace that line for this
      Vector3 move = Camera.transform.right * x + Camera.transform.forward * z;
      And at the start of the code add this:
      public transform Camera;
      Then go to the player inspector, go to the script part and drag the camera in the transform section similar to groundcheck
      Finally, grab the Mouse script, remove it from the player and add it to the camera object
      I hope i explained it right and it works for you

    • @AloricGG
      @AloricGG 6 หลายเดือนก่อน

      @@meth2326 For those of you who are getting an error trying this, change public transform Camera; to public Transform Camera;

    • @ShiridoTunes
      @ShiridoTunes 6 หลายเดือนก่อน

      ​@@meth2326 I encountered a problem. When you look up and hold forward you fly forward.

    • @thodorisevangelakos
      @thodorisevangelakos 5 หลายเดือนก่อน

      yeah your entire player rotates, thus the ground check is levitating, while your body is keeping you from falling below the floor. I spend an unholy amount of time debugging that

    • @thodorisevangelakos
      @thodorisevangelakos 5 หลายเดือนก่อน +1

      @@meth2326 what I ended up doing is I made an empty head object, attached a sphere and the camera to that, and made the body rotate aroundthe y axis based on the head rotation. Player movement is on the player object and mouse movement on the head object

  • @Kage_Yurei
    @Kage_Yurei 6 หลายเดือนก่อน +4

    if you want to sprint, simply set the movement speed to increase if ur pressing leftshift

  • @CrazyNickVOD
    @CrazyNickVOD 5 หลายเดือนก่อน +3

    If having trouble with jumping not working, increase the ground distance within the player movement script (0.4 to 2.0 worked for me).❤

    • @maferrmancilla6281
      @maferrmancilla6281 หลายเดือนก่อน

      you saved meeeee with this

    • @aggroplayz1897
      @aggroplayz1897 13 วันที่ผ่านมา

      Thanks a LOT
      It solved the problem
      Also if it still doesn't work you have to also change it in the inspector

  • @striverfor7628
    @striverfor7628 4 หลายเดือนก่อน

    Personal bookmarks
    1:27
    2:38 MouseMovement script, coding.

  • @ZrionDev
    @ZrionDev ปีที่แล้ว +1

    you deserve more subs becuse you are a good game dev an your a amazing

  • @erikbach8436
    @erikbach8436 11 หลายเดือนก่อน

    this series looks really good

  • @realworldcodingapplications
    @realworldcodingapplications 6 หลายเดือนก่อน +1

    love this man thank you so much.

  • @gabriellarmour2076
    @gabriellarmour2076 8 หลายเดือนก่อน

    im gonna use this series to help me build a fun shooter similar to ow

  • @Catm7789
    @Catm7789 วันที่ผ่านมา

    help when looking it rotates the entire character and won't jump because the ground check is no longer detects the ground cus the ground check sideways

  • @StephenWebb1980
    @StephenWebb1980 หลายเดือนก่อน +1

    why are you using the physics.checksphere when also using a character controller? there is a .IsGrounded bool in the CharacterController class

  • @darcycharlton6341
    @darcycharlton6341 9 หลายเดือนก่อน +7

    @Mikes-Code with your MouseMovement script you have the Player rotation on the x and z axis frozen so that the PlayerBody doesn't tilt in all directions. Care to explain how you did that as this is an issue that is apparently common amongst your viewers.

  • @Gamerytbg
    @Gamerytbg 5 วันที่ผ่านมา +1

    Why i fly not walking😂😂

  • @scottmedhaug4107
    @scottmedhaug4107 ปีที่แล้ว +1

    thank you a very good teacher

  • @paulberry3359
    @paulberry3359 ปีที่แล้ว +1

    Just subbed for your Survival game and then this drops...... so excited !

  • @JenniferAbro-t3v
    @JenniferAbro-t3v 7 วันที่ผ่านมา

    when i jump while looking straight i start falling slower than when i jump up and when i look down it looks normal how do i fix this?

  • @BRJEShKashyap-i7n
    @BRJEShKashyap-i7n 9 หลายเดือนก่อน

    This series is very halpful and awesome can you make some series like this we are interested this content love you sir 🤩🤩🤗🤗🥰🥰🥰🥰🥰🥰😍😍😍😍😍😍

  • @LostAngel175
    @LostAngel175 ปีที่แล้ว

    wow, I find this great series.woo - hoo🥰🥰

  • @Me_Camel
    @Me_Camel 5 หลายเดือนก่อน

    what was the cut at 2:30 where the plane just got rlly big for??? idk how to make it look like that and it ruins the game

    • @YNGSprkzy
      @YNGSprkzy 4 หลายเดือนก่อน

      just upscale the plane my guy😭

  • @Anakin.Skywalker44
    @Anakin.Skywalker44 9 หลายเดือนก่อน +1

    im at the end of the tutorial and everything is working but i automatically move backwards when i press play and i cant make it stop, i can counteract by walking forward but not stop it, the automatic backwards movement is slightly slower than normal movement since i can walk forward but very slowly

    • @Anakin.Skywalker44
      @Anakin.Skywalker44 9 หลายเดือนก่อน

      i realised its probably because of my g920 that was plugged in and after unplugging and restarting unity editor it works again, just replying this in case anyone gets same problem and has a steering wheel or other controller plugged in that may interfere

  • @RealOctoRBX
    @RealOctoRBX หลายเดือนก่อน

    When I try to open the project it just says Project failed to open (This project is not valid) what should I do?

  • @Laluka
    @Laluka 3 หลายเดือนก่อน

    i have several issues and those are
    1- groundCheck is always true
    2- player moving everywhere looking at. Including up and down
    3- player gliding down whether gravity is too high or low.

  • @GravitraxMasters69
    @GravitraxMasters69 ปีที่แล้ว

    you are very underated

  • @RomalNasiri-y5x
    @RomalNasiri-y5x 10 หลายเดือนก่อน +2

    wow Thank you!
    you are the best Teacher that i see in my life ❤

  • @ItzMagmy
    @ItzMagmy หลายเดือนก่อน +1

    Transform.localRotation won’t work it says the problem is (CS0120) and An object reference is required for the non-static field, method, or property plz help
    Edit : NVM CHAT GPT DA GOAT

  • @zapblackcap
    @zapblackcap 8 หลายเดือนก่อน

    thank you and I love you man

  • @WarrenLaPietra
    @WarrenLaPietra ปีที่แล้ว +4

    Everything is not working, I cannot jump, I instantly fly away XD

    • @kamilbrawl1218
      @kamilbrawl1218 ปีที่แล้ว

      yes me too XD

    • @spec45as1
      @spec45as1 ปีที่แล้ว

      @@kamilbrawl1218check the gravity parameter in the inspector

    • @super_art_master.
      @super_art_master. 10 หลายเดือนก่อน

      Decrease jump power

  • @gamareaper2979
    @gamareaper2979 ปีที่แล้ว

    thanks mike's code i done my game

  • @exskewesme
    @exskewesme 20 วันที่ผ่านมา

    Assets\Scripts\MouseMovement.cs(13,11): error CS1519: Invalid token 'float' in class, record, struct, or interface member declaration. How can i fix this?

    • @Mikes-Code
      @Mikes-Code  20 วันที่ผ่านมา

      hey, there seems to be a probelm on line 13, of the mousemovement script. could you paste line 13?

  • @tanuki4games
    @tanuki4games 8 หลายเดือนก่อน

    At 3:26 how did you put that special character that was after the "xRotation"?

    • @Mikes-Code
      @Mikes-Code  8 หลายเดือนก่อน

      This is just the "minus" character - and the "equals" character =.

  • @leonidzolotarov5059
    @leonidzolotarov5059 9 หลายเดือนก่อน

    Hi, @Mike!
    Please can you help me - my Player doesn't want to Jump!
    His velocity always decreases and I don't know how to fix it.
    In debugger I checked what line " velocity.y = Mathf.Sqrt(_jumpHeight * -2f * _gravity);" executes, bot no effect!
    Please help, what I missed?
    Thank you

    • @Try_Not_To_Sing
      @Try_Not_To_Sing 5 หลายเดือนก่อน

      take away the underscores

  • @ENDYZ
    @ENDYZ หลายเดือนก่อน

    beautiful, thank u

  • @alexchrist9796
    @alexchrist9796 หลายเดือนก่อน

    Hi, im new to this unity stuff and i dont really understand on that code thing you type, can you make a tutorial for a real beginners on how to use one? Really enjoy on your video though, you are a great teacher.

    • @Mikes-Code
      @Mikes-Code  หลายเดือนก่อน

      @@alexchrist9796 actually, a c# tutorial for begineers is planned in the near future.

  • @dylanbackstrum8856
    @dylanbackstrum8856 10 หลายเดือนก่อน +1

    Can anyone help me with this? So i followed this whole video through yet afterwards i realized the entire body was rotating instead of just the camera, i dont know if this is correct because, since the entire body moves then when i am looking 90 degrees down then i cant just (because groundCheck is lifted off the ground). This also causes the issue where i cant move with w or d while looking down because my character is moving forwards (which is in this case down because im looking down). This makes it so looking down even a little slows down my character. Is there any way to fix this?
    Btw: I cannot just set the bottom clamp to lower because it still slows me down when im looking even slightly downwards

    • @ayreeb
      @ayreeb 10 หลายเดือนก่อน

      Having the exact same problem

    • @meth2326
      @meth2326 7 หลายเดือนก่อน +1

      You need to go to the part where it says:
      Vector3 move = transform.right * x + transform.forward * z;
      Replace that line for this
      Vector3 move = Camera.transform.right * x + Camera.transform.forward * z;
      And at the start of the code add this:
      public transform Camera;
      Then go to the player inspector, go to the script part and drag the camera in the transform section similar to groundcheck
      Finally, grab the Mouse script, remove it from the player and add it to the camera object
      I hope i explained it right and it works for you

  • @soco5338
    @soco5338 3 หลายเดือนก่อน

    I had a problem with the character doing this hopping movement when they looked too far up so I made a slight change.
    Inside the PlayerMovement script, inside the Update method, I got rid of the CheckSphere raycast and replaced it with a regular Raycast, checking from the groundCheck position, downwards, for a length of groundDistance, still checking for groundMask.
    Back in Unity, I positioned the GroundCheck object in the center of the Player object and made the groundDistance value 2, since the body is scaled to 1.7. Basically the distance needs to be slightly higher than the player Y scale.
    I don't know if this will conflict with anything in the future though because I've only completed the first two videos. Technically don't need the Debug line, but it's nice to see
    isGrounded = Physics.Raycast(groundCheck.position, Vector3.down, groundDistance, groundLayer);
    Debug.DrawLine(groundCheck.position, groundCheck.position + Vector3.down * groundDistance, Color.red);
    if (isGrounded && velocity.y < 0)
    {
    velocity.y = -2f;
    }

  • @PrismX_8
    @PrismX_8 5 หลายเดือนก่อน +3

    Make this your movement script if you want to be able to sprint when holding "Shift": using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayerMovement : MonoBehaviour
    {
    private CharacterController controller;
    public float speed = 12f;
    public float sprintSpeed = 18f; // Add a sprint speed
    public float gravity = -19.62f; // More realistic gravity
    public float jumpHeight = 3f;
    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;
    private Vector3 velocity;
    private bool isGrounded;
    public Transform Camera;
    void Start()
    {
    controller = GetComponent();
    }
    void Update()
    {
    GroundCheck();
    Move();
    }
    void GroundCheck()
    {
    isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
    if (isGrounded && velocity.y < 0)
    {
    velocity.y = -2f; // Reset velocity when grounded
    }
    }
    void Move()
    {
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");
    Vector3 move = Camera.transform.right * x + Camera.transform.forward * z;
    // Check if the Shift key is pressed to sprint
    if (Input.GetKey(KeyCode.LeftShift))
    {
    controller.Move(move * sprintSpeed * Time.deltaTime);
    }
    else
    {
    controller.Move(move * speed * Time.deltaTime);
    }
    if (isGrounded && Input.GetButtonDown("Jump"))
    {
    velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
    }
    // Apply gravity
    velocity.y += gravity * Time.deltaTime;
    // Apply final movement with gravity
    controller.Move(velocity * Time.deltaTime);
    }
    }

    • @tohiroGm
      @tohiroGm 4 หลายเดือนก่อน

      Hi, very cool everything works! Can you please tell me if you have fixed the fact that the player does not go looking down or bounces looking up?

    • @PrismX_8
      @PrismX_8 4 หลายเดือนก่อน +1

      @@tohiroGm that is because you are a sphere right now and when you look up you and your sphere collider also look up with you therefore your jump point isn’t on the ground when looking up or down I don’t know how to fix this problem tho

    • @tohiroGm
      @tohiroGm 4 หลายเดือนก่อน

      ​@@PrismX_8 I agonized with this shit for a long time, decided to just limit the viewing angle in the game

    • @PrismX_8
      @PrismX_8 4 หลายเดือนก่อน

      @@tohiroGm that could work you could also mabye but three different jumping points or ask chat gpt

  • @SolarSoftMedia
    @SolarSoftMedia 8 หลายเดือนก่อน

    I wonder if this course will show us how to make our own weapons instead of getting free premade assets. I'd really like to learn how to make weapons, probably something done in blender.

  • @FactoRunner
    @FactoRunner ปีที่แล้ว +2

    so this basically works except the fact that I can fly and I have exactly the same code

  • @dorianmayamba6177
    @dorianmayamba6177 8 หลายเดือนก่อน +1

    My character controller collides with the plane, making it falls on gameplay. Any tips?

    • @ozu7779
      @ozu7779 6 หลายเดือนก่อน

      check colliders and make sure that player up to the platform

    • @comhalain
      @comhalain หลายเดือนก่อน

      more specifically, you can remove the cillinder collider and increase the height of the "character controller" on the Player to cover the whole figure

  • @donrubenstein4375
    @donrubenstein4375 7 หลายเดือนก่อน

    All works except jump, on a MacBook pro mousepad works but space bar not allowing jump. Anything I need to change in the Project settings??

  • @CharCoalTheBeast
    @CharCoalTheBeast ปีที่แล้ว

    It did not work for me. It said,
    [16:13:30] Assets\Scripts\MouseKovement.cs(27,24): error CS0131: The left-hand side of an assignment mus be a variable, property or indexer

    • @chasesanders7070
      @chasesanders7070 11 หลายเดือนก่อน

      Yeah i got that too

    • @chasesanders7070
      @chasesanders7070 11 หลายเดือนก่อน +1

      I had that and just realised that the symbol just after the (“Mouse X”) is an asterisk * not an equals sign

  • @yonaberrebi2452
    @yonaberrebi2452 3 หลายเดือนก่อน +1

    it is aproblem if i use Unity VR Project?

    • @Mikes-Code
      @Mikes-Code  3 หลายเดือนก่อน +1

      @@yonaberrebi2452 well, you can technically borrow some of code, lets say, the weapon logic to work in VR, but most of the tutorial is not compatible with VR and is not going to work, unless you know how to create your own VR controls.
      The problem is that VR deals with movement/controls/interactions in a completely different way.

    • @yonaberrebi2452
      @yonaberrebi2452 3 หลายเดือนก่อน

      @@Mikes-Code okay thanks

  • @daniilshipilov-u7i
    @daniilshipilov-u7i 5 หลายเดือนก่อน

    why is my camera so strange, I followed the whole video very well but nothing works, the body follows the movement of the camera, the movement of the player is like this part did not persist, so I need help

  • @Mr.Fanman
    @Mr.Fanman 10 หลายเดือนก่อน +1

    Error with the cursor : Cannot implicitly convert type 'UnityEngine.CursorLockMode' to 'UnityEngine.Cursor'

    • @Jorgoz2
      @Jorgoz2 8 หลายเดือนก่อน

      Same

    • @Jorgoz2
      @Jorgoz2 8 หลายเดือนก่อน

      Did you fix it

    • @Mr.Fanman
      @Mr.Fanman 8 หลายเดือนก่อน

      Yeah, I fixed it. I found a mistake in my code

    • @Mr.Fanman
      @Mr.Fanman 8 หลายเดือนก่อน

      Just look carefully through your code

  • @ssrs9661
    @ssrs9661 8 หลายเดือนก่อน +5

    the code doesnt work. it compile fine but the character doesnt move

    • @beanboi3178
      @beanboi3178 8 หลายเดือนก่อน

      works for me

    • @ssrs9661
      @ssrs9661 8 หลายเดือนก่อน

      @@beanboi3178 how man? how?

    • @beanboi3178
      @beanboi3178 8 หลายเดือนก่อน

      @@ssrs9661 idk, I’m not great at coding, i just copied everything in the video and it worked, maybe you missed something in the unity editor or code

    • @alan456M
      @alan456M 6 หลายเดือนก่อน

      same here, I did everything he said and nothing happens

    • @vijaylaxmi8177
      @vijaylaxmi8177 5 หลายเดือนก่อน

      @ssrs9661 try to add the script in the player from add component option

  • @rivertorres0227
    @rivertorres0227 9 หลายเดือนก่อน

    As soon as I fixed an error involving the jump input, I started falling through the ground when I enter play mode. What should I do?

    • @Mikes-Code
      @Mikes-Code  9 หลายเดือนก่อน

      Make sure the player is above the ground, and that he has a collider, also the ground should have a collier

    • @Saroshxeditzz
      @Saroshxeditzz 2 หลายเดือนก่อน

      how did you solved it

    • @comhalain
      @comhalain หลายเดือนก่อน +1

      @@Saroshxeditzz With help from a friend, I removed the cillinder collider and increased the height of the "character controller" on the Player to cover the whole figure (you can see the lines of the colliders to compare) and that stopped the falling.

  • @Oslexed
    @Oslexed หลายเดือนก่อน

    I have a problem when I spin my camera the character moves also

    • @Антон-л6я8у
      @Антон-л6я8у หลายเดือนก่อน

      The smartest John. You need MouseMovement ONLY ON THE CAMERA

  • @zeekkh
    @zeekkh ปีที่แล้ว

    Is there a particular reason why you're using xRotation on the player transform.x instead of the camera.transform.x?

  • @legoalternator2.014
    @legoalternator2.014 ปีที่แล้ว

    ummmm teres a problem im having wen i look doun all the way and try to jump i cant same gose to wen i look up all the wai to the max i stil cant jump do you noue wi or if tere is a problem in the code tat make it not let me jump?

    • @legoalternator2.014
      @legoalternator2.014 ปีที่แล้ว

      but wen mi camera is straight i stil kan jump
      forgot to mention

    • @MattisDeveloper
      @MattisDeveloper ปีที่แล้ว

      @@legoalternator2.014 Thats becouse you rotate your playerprefab when you look up/down. So your groundcheck will be in the "air" and then you cant jump. Look up/down should only effect camera and not the rotation of player body

  • @jclouis7117
    @jclouis7117 หลายเดือนก่อน

    hello im not able to move my camera ( 6.:10)on play mode pls help im strugling

    • @Mikes-Code
      @Mikes-Code  หลายเดือนก่อน

      @@jclouis7117 hey, what happens when you press on play? Is the game running? Are you getting any errors in the console? Did you make sure the scripts are saved and placed on the player correctly. That the camera is a child of the player?

  • @DeathCameForYou147
    @DeathCameForYou147 8 หลายเดือนก่อน

    Which Engine Version are you using?

  • @kaszana9698
    @kaszana9698 10 หลายเดือนก่อน +4

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayerMovement : MonoBehaviour
    {
    private CharacterController controller;
    public float speed = 12f;
    public float gravity = 9.81f * 2;
    public float jumpHeight = 3f;
    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;
    Vector3 velocity;
    bool isGrounded;
    bool isMoving;
    private Vector3 lastPosition = new Vector3(0f, 0f, 0f);
    // Start is called before the first frame update
    void Start()
    {
    controller = GetComponent();
    }
    // 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);
    if (lastPosition != gameObject.transform.position && isGrounded == true)
    {
    isMoving = true;
    }else
    {
    isMoving = false;
    }
    lastPosition = gameObject.transform.position;
    }
    }

  • @galberger3937
    @galberger3937 ปีที่แล้ว

    Hi.
    I got stuck here: error CS1503: Argument 2: cannot convert from 'UnityEngine.Transform' to 'float'
    how to fix it?
    i can't find the right place in my code.

    • @Mikes-Code
      @Mikes-Code  ปีที่แล้ว

      Please paste the entire error code, it should say in which script, and even on what line is the error.

    • @galberger3937
      @galberger3937 ปีที่แล้ว

      This is my code:
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class PlayerMovement : MonoBehaviour
      {
      private CharacterController controller;
      public float speed = 12f;
      public float gravity = -9.81f * 2;
      public float jumpHeight = 3f;
      public Transform groundCheck;
      public float groundDistance = 0.4f;
      public LayerMask groundMask;
      Vector3 velocity;
      bool isGround;
      bool isMoving;
      private Vector3 lastPosition = new Vector3(0f, 0f,0f);
      void Start()
      {
      controller = GetComponent();
      }
      // Update is called once per frame
      void Update()
      {
      // Ground Check
      isGround = Physics.CheckSphere(groundCheck.position, groundCheck, groundMask);
      // Resetting the default velocity
      if(isGround && velocity.y

    • @galberger3937
      @galberger3937 ปีที่แล้ว

      Please help?

    • @Mikes-Code
      @Mikes-Code  ปีที่แล้ว

      @@galberger3937 hey, can you post the entire error description?

    • @galberger3937
      @galberger3937 ปีที่แล้ว

      ​@@Mikes-Code This is the entire line of the error:
      [12:07:44] Assets\Scripts\PlayerMovement.cs(37,62): error CS1503: Argument 2: cannot convert from 'UnityEngine.Transform' to 'float'
      if you still have the code can you send it to me so i can cope and past it?
      sometime that is how t i can fix this problems.

  • @012-prog
    @012-prog 2 หลายเดือนก่อน

    Mike can you tell me place to learn c# from 0% to 100% please reply me

    • @Mikes-Code
      @Mikes-Code  2 หลายเดือนก่อน

      @@012-prog I actually don't really know any good c# tutorials, although I'm sure they are out their.
      Just look for a complete one, and take it slow, learn all the basics.

    • @squarecircle1473
      @squarecircle1473 2 หลายเดือนก่อน

      go to pluralsight. Good courses and learning paths.

  • @FireSeaGaming
    @FireSeaGaming ปีที่แล้ว +3

    Please add storage system like we could place our inventory items inside chest and could you make a system for random items inside chest for looting purpose in your survival series please...

    • @sargent5410
      @sargent5410 ปีที่แล้ว

      he will he just started

  • @Jorgoz2
    @Jorgoz2 8 หลายเดือนก่อน

    With the MouseMovememt script it has a bunch of errors like it already has a definition for mousemovement and stuff

  • @Gunnerrrr2k
    @Gunnerrrr2k ปีที่แล้ว

    cab you get gun model form sketfab ?

  • @ret4rd3dmonk
    @ret4rd3dmonk 4 หลายเดือนก่อน

    I followed the tutorial and in the end my character keeps going up in the sky and never stops. ant tips on how to fix that??

    • @eatower2
      @eatower2 4 หลายเดือนก่อน

      Gravity on the rigidbody?

    • @ret4rd3dmonk
      @ret4rd3dmonk 4 หลายเดือนก่อน

      @@eatower2 you mean the player movement script??? Its 19.62 on it and the speed is 12 and the jump height is 3

    • @eatower2
      @eatower2 4 หลายเดือนก่อน

      @@ret4rd3dmonk try -19.62?

    • @eatower2
      @eatower2 4 หลายเดือนก่อน

      @@ret4rd3dmonk did you try it at - 19.26?

  • @worlore1651
    @worlore1651 ปีที่แล้ว +1

    Not finishing survival series?

    • @SloudPL
      @SloudPL ปีที่แล้ว +1

      I think he will continue it but later

    • @Mikes-Code
      @Mikes-Code  ปีที่แล้ว +5

      The survival series will still continue. New episode soon.
      This FPS series is still experimental, i want to see if people even like it.

    • @worlore1651
      @worlore1651 ปีที่แล้ว

      @@Mikes-Code ok thanks, was just wondering, take your time

    • @worlore1651
      @worlore1651 ปีที่แล้ว

      @@Mikes-Code I like the fps design btw

  • @AbdulmalikKH-g2c
    @AbdulmalikKH-g2c ปีที่แล้ว +2

    I don't know why but I instantly fly ive tried fixing the position but no result

    • @laughy2016
      @laughy2016 9 หลายเดือนก่อน

      make sure your gravity is negative. That happened to me but once I changed the gravity to negative I was fine.

  • @prodluvin
    @prodluvin 9 หลายเดือนก่อน

    Is there download link to this game it seems fun !! I love the vids 🔥🔥

  • @MrLixono23
    @MrLixono23 8 หลายเดือนก่อน

    can you make a full FPS multyplayer tutorial ?

  • @aliuysun5544
    @aliuysun5544 7 หลายเดือนก่อน

    Thank you it was so clear explain thats great for me (this Series awesome)

  • @ArindamBhattacharya
    @ArindamBhattacharya 10 หลายเดือนก่อน

    how did you got this code theme in visual studio pls tell then i will subscribe ok

  • @MafutaGames
    @MafutaGames 4 หลายเดือนก่อน

    I had to make my Top Clamp = 90 and Bottom Clamp = -90 in unity 2022.3.25 for it to work right. Player Body was falling over otherwise.

    • @Saroshxeditzz
      @Saroshxeditzz 2 หลายเดือนก่อน +1

      did you solved problem

  • @kindguy4330
    @kindguy4330 5 หลายเดือนก่อน

    my character whole body is moving can anyone help me?
    after applying mousemovement script, my character body is rotating

  • @Anonymous-y8l3s
    @Anonymous-y8l3s ปีที่แล้ว +1

    Hey, so weird question, but can you make enemies that attack with ranged weapons like guns and as well melee, cuz i do wanna make both for my game.

  • @mattg1345
    @mattg1345 ปีที่แล้ว

    Are you going to continue the survival series as well as this ? Also why do you choose the old input system over the new one ?

    • @Mikes-Code
      @Mikes-Code  ปีที่แล้ว +1

      Yes the survival series will still continue.
      There is actually no real reason that I use this input system. But maybe I will change it in the future, if I see that it limits us in some way.

  • @alpmagirus
    @alpmagirus ปีที่แล้ว

    i thought mouse inputs are already frame independent arent they?

    • @alpmagirus
      @alpmagirus ปีที่แล้ว +1

      Guy named "Eric5h5" in Unity Forum:
      "The documentation is correct on both counts; it’s not a matter of “which one is it”. GetAxis(“Horizontal”) by default is keyboard input and has nothing to do with mouse movement. GetAxis(“Mouse X”) is mouse movement and is always inherently framerate-independent: if you move your mouse two inches, it takes the same time for you to do that regardless of how fast your computer is. (If the framerate affects your own physical movement speed, I would start to worry. :wink: ) So you should absolutely not use Time.deltaTime with mouse movement, since that will cause the code to become framerate-dependent."

  • @RustyBear
    @RustyBear ปีที่แล้ว

    The thumbnail 😂

  • @corbynlarsson9279
    @corbynlarsson9279 11 หลายเดือนก่อน

    Anyone got the code? i tried recreating it myself but the clamps wont work and the sensitivity is whack

  • @NottSpigitt
    @NottSpigitt 6 หลายเดือนก่อน

    I've used roblox studio and learned the layout... do you think this is enough to be able to follow along with this? ;>

  • @GamerBlack-YT
    @GamerBlack-YT ปีที่แล้ว

    I'm stuck here: I wrote the same script as you, but somehow I can float, why?

  • @rukj8653
    @rukj8653 5 หลายเดือนก่อน

    the "z" in movement code in not working

  • @ssrs9661
    @ssrs9661 7 หลายเดือนก่อน +2

    the character isnt jumping please help

    • @plank8053
      @plank8053 7 หลายเดือนก่อน

      try to use Debug.log(isGrounded); If the value is Flase the player is not on the ground and if its true is on the ground. The problem with jumping is that the groundDistance = 0.4f is low value for the radius of the CheckSphere. So basically if u are looking down or up the GroundCheck(the empty body under the player) is way to far from the ground. Try to set the value of groundDistance to 5.

  • @SpookyAdoom
    @SpookyAdoom 17 วันที่ผ่านมา

    One small problem, it still lets me jump infinitely

  • @BadApple-um7vb
    @BadApple-um7vb 6 หลายเดือนก่อน

    my character cant look top and down its blocked but not correct

  • @daviddistefano7623
    @daviddistefano7623 5 หลายเดือนก่อน

    Top for me❤

  • @OGKend
    @OGKend 5 หลายเดือนก่อน +1

    when i look around the camera moves

    • @IVANZOLO_2005
      @IVANZOLO_2005 5 หลายเดือนก่อน

      i guess you have to parent it to the player if you did this you need to add the script with the mouse to the camera i think but idk

  • @shipwreckjackson2899
    @shipwreckjackson2899 10 หลายเดือนก่อน

    hey im having a problem with this error Assets\Scripts\MouseMovement.cs(21,48): error CS1002: ; expected do you think you can help

  • @Clister522
    @Clister522 7 หลายเดือนก่อน

    can anyone provide me the script of player movements plz?

  • @JellyJunk-me1vh
    @JellyJunk-me1vh 6 หลายเดือนก่อน

    Strange? but i'm tottali copied this code and game still not seeing mouse

    • @dwapy5580
      @dwapy5580 5 หลายเดือนก่อน

      Same

  • @ShadowElefanti
    @ShadowElefanti 3 หลายเดือนก่อน

    thx for the movement but i cant jump

  • @ashtheone-m9e
    @ashtheone-m9e 4 หลายเดือนก่อน

    can i have link for codes🙏

  • @DeagleAssault
    @DeagleAssault 9 หลายเดือนก่อน

    when i look around my hole player bod moves

  • @The_song_artist.
    @The_song_artist. 3 หลายเดือนก่อน

    Can Mr.mike or anyone pls provide all the codes required in this entire project within 2 days 🙏🙏

    • @The_song_artist.
      @The_song_artist. 3 หลายเดือนก่อน

      Who has done it already can help too

    • @The_song_artist.
      @The_song_artist. 3 หลายเดือนก่อน

      Because I Am a beginner and struggling a lot

  • @NewYorkNixDa
    @NewYorkNixDa ปีที่แล้ว

    why using old input system?

    • @Mikes-Code
      @Mikes-Code  ปีที่แล้ว +1

      You can use the new one if you want.
      I just don't like it.

  • @illuminatisl888
    @illuminatisl888 9 หลายเดือนก่อน

    I can't jump😢 space isn't working? I did everything as you said

    • @munimkhan2137
      @munimkhan2137 9 หลายเดือนก่อน +1

      bro adjust your ground check position keep it close to the player feet. I had also the same problem but now it is working goood😊

  • @BlueGuyBR12345
    @BlueGuyBR12345 3 หลายเดือนก่อน

    I can't open the scrips

    • @Mikes-Code
      @Mikes-Code  3 หลายเดือนก่อน

      @@BlueGuyBR12345 Do you have a code editor installed? When you install a new Unity Version it always offers to install Visual Studio.

  • @MaxSpencerNash
    @MaxSpencerNash 6 หลายเดือนก่อน

    For some reason Jumping did not work for me.

  • @DeathCameForYou147
    @DeathCameForYou147 8 หลายเดือนก่อน

    A Question

  • @pratyushkasi7848
    @pratyushkasi7848 11 หลายเดือนก่อน +23

    You neeed to explain wha you are doing, you do everything sp fast its so hard to follow even if you set the playbackspeed slower, You somehow access something we dont know how to do what you did because you dont explain it.

    • @Mikes-Code
      @Mikes-Code  11 หลายเดือนก่อน +13

      Hey, as mentioned at the beginning of this series, it is a rather fast-paced series, not meant for beginners.
      It is for developers who are comfortable with Unity and just want to know how to add FPS elements to their game.
      For example, my Survival series is for beginners and it starts very slowly where I explain everything.
      I still think it is possible for beginners to follow along with this series, it will just require a higher learning curve.

    • @Danda1374
      @Danda1374 10 หลายเดือนก่อน +1

      True

    • @EvanMaruszewski-nt5up
      @EvanMaruszewski-nt5up 5 หลายเดือนก่อน +1

      Facts

    • @The_song_artist.
      @The_song_artist. 3 หลายเดือนก่อน

      Pls can you provide all the codes