How to do FPS Smooth Crouching! - Ep. 3

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 2024
  • #gamedev #unity
    We're going to building out smooth crouching in this video. We'll be handling objects above our heads, smoothing out the movement of the crouch, and more. Thanks for watching!
    Website: www.hightailga...

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

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

    A way of making the crouching even smoother is by also moving the camera. I Lerp the camera position when crouching as well as Lerping the player controller height to make the camera go lower when crouching. I lerp the camera to the centre of the playcontroller (+ an offset so it isn't completely in the centre) when crouching and back to it's original position when standing. Since i am also lerping back, the movement is smooth cause the camera is now moving independently and is not affected by the jitter caused by the player controller pushing the ground.
    But be careful, this might mess with your jump. To not mess up your jumping you need to do so the camera snaps to the centre of your player + an offset (wich has to be the normal distance the camera is from the centre of your player) when standing up. The same way Ajackster shows how to snap the height. That way you stand before jumping, therefore snapping your camera to an offset from the centre of the player, instead of lerping to the normal height it's at.
    Hope this wasn't too confusing

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

      That's a really neat idea, maybe I'll make a 2nd video about making the crouch smoother

    • @zig8925
      @zig8925 3 ปีที่แล้ว

      @@Ajackster It's not fool proof and can mess with some stuff. I ended up having some problems when crouching and jumping quickly. But it does make it look smoother when going up and down. You also need to use the right Update method. I find that LateUpdate works best for me when interpolation

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

    even in the videos it is visible the player is shuttering when it stands up
    that transform position to move the player doesn't do anything

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

      oh, now i got it
      13:40
      instead of a transform position, use a character controller dot move to move the player upwards
      for some reason the character controller doesn't let you move the object freely with transform positions

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

      @@DevVand thanks

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

    The way you could avoid the effect you where talking about is by also changing the center of the character controller, instead of the center being in the middle of your controller when you crouch, the center on the Y could be lower so that it matches your height.

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

    but when i crouch the whole player is sinking

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

    Hi! First of all thanks a lot for this tutorials, this is helping me a lot since I've only developed 2d games until now and Valorant has in my opinion one of the best movement systems right now in tactical fps. I have a question that is bothering me (I've been hitting my head 3 days straight on this). I need a fix for this problem, when i strafe left and right in Valorant, I can suddenly stop the movement by pressing the opposite key (e.g. if I press the A key to go left I can stop almost immediatly by pressing the D key). This doesn't happen when I try it and I would like to know a possible fix for this.Thank you so much again for the help! Hope you can help me.

    • @Ajackster
      @Ajackster  4 ปีที่แล้ว

      Hey! Glad you're enjoying the series and that you're getting into 3d games. I'm assuming this is some side effect of the GetAxis function where the values for input aren't cancelling each other out. There are a couple solutions to this that you can implement.
      1.) Simplest solution is use GetAxisRaw instead of GetAxis. GetAxisRaw will either return a -1 0 1 and seems to handle the cancel out.
      2.) You could listen to keyboard events and write out some logic to cancel out movement if both are pressed.
      Lemme know if you have any other questions!

  • @ToskiiiVAL
    @ToskiiiVAL 2 ปีที่แล้ว

    Hi Ajackster I'm having some problems with the crouching mechanic where I'm after uncrouching under the box, I'm stuck and can not move, my code is exactly the same as yours and unity comes up with no errors, if you have any solution as to why this could be happening please lmk thanks.

    • @willydevz
      @willydevz 2 ปีที่แล้ว

      like it dosent stand up? if so its because the raycast is hitting the player

  • @omergamerxd2113
    @omergamerxd2113 3 ปีที่แล้ว

    can i take the code