Simple Character Controller with Double Jump in Unity

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 134

  • @harrison298
    @harrison298 3 года назад +7

    Thanks for the tutorial.
    For anyone wondering, the double jump bit starts at 9:30

  • @Osoclever
    @Osoclever 10 месяцев назад +1

    Watched so many tutorials just wanted to stop the infinite jump thank you very much for this video.

  • @TheRealMonstaa
    @TheRealMonstaa 3 года назад +2

    I've seen a ton of movement tutorials and tried out many things but this one was really the best one I've come by! Great stuff, next up is your 3rd person camera tutorial!

    • @henstudios_official6498
      @henstudios_official6498 2 года назад +1

      Yes, I agree! I spent 5 days trying to find one like this for bolt, but I had to get C# for this one so I held off for a while, but then I realized I didn't need to learn and just gain knowledge from this.

  • @josekarnikowski1711
    @josekarnikowski1711 Год назад

    Dude. You explain in a very detailed way! Really nice video!

  • @waffoo101thedankest5
    @waffoo101thedankest5 4 года назад +9

    You are my new favorite youtuber, no over exaggerating. Thank you so much!!!
    I have one question, how to I make my "Player" be able to interfere with objects, such as push cubes around?

    • @DenizSimsek
      @DenizSimsek  4 года назад +3

      Thank you very much for your comments! I will extend this series with the topics like intearacting objects and NPCs.

    • @ktz2625
      @ktz2625 4 года назад +1

      I use the "Rigidbidy" component istahead of the "Character controller". It makes it easier to understand and you don't have to do much calculations. You can move stuff around, and it detects collisions very well.
      You don't go through walls xD

    • @DenizSimsek
      @DenizSimsek  4 года назад

      I realized I could have answered this question. You can use sphere colliders as triggers around the game objects to allow them to be interactable. If the Player is inside the collider, show a text that says Press E to Interact and then inside onTriggerStay detect the input and do whatever you want the interaction to do. Good luck!

    • @ATdeVerdad1
      @ATdeVerdad1 3 года назад

      I think you can just add a Rigidbody to the object you want to move. I don't know if you have to toggle "Is Kinematic".

    • @waffoo101thedankest5
      @waffoo101thedankest5 3 года назад

      @@ATdeVerdad1 its okay this comment was 7 months ago

  • @Faisal-jo5vk
    @Faisal-jo5vk 3 года назад

    i didnt exactly do what you did, and idk what exactly i did but im able to double jump now, thx!!

    • @Faisal-jo5vk
      @Faisal-jo5vk 3 года назад

      the code i was using before watching your video was from here --> ruclips.net/video/tXDgSGOEatk/видео.html

  • @cprograms4280
    @cprograms4280 4 года назад +2

    I cannot tell you how much this helped thanksss

  • @sergejssehonins7629
    @sergejssehonins7629 3 года назад

    Best video about character control that I have ever seen.

  • @pacocastaneda525
    @pacocastaneda525 3 года назад +3

    Great video, can't wait for the camera tutorial :D

    • @zouglou
      @zouglou 3 года назад

      xD you just need to put the camera in the character

  • @Crons-v3f
    @Crons-v3f 3 года назад +2

    Finally, something that works 100%, thank you so much! :)

  • @jamesclarke1686
    @jamesclarke1686 3 года назад

    I love the birds in the background

  • @spacemankam2525
    @spacemankam2525 4 года назад +3

    Great starting place, thanks man

  • @doodledoo5611
    @doodledoo5611 4 года назад

    your video was the only one that worked, Thanks!

  • @platypus4
    @platypus4 2 года назад

    Thank you, you are the best!

  • @Etka06
    @Etka06 2 года назад

    Thank you for tutorial.

  • @268lines6
    @268lines6 3 года назад

    i love this video, really really clean and clear

  • @Kevinsiman
    @Kevinsiman 3 года назад +16

    It's a really good tutorial. However, the variable "_directionY" keeps increasing it's value until you jump. So, if you fall from any lengh without jumping, you will fall very fast.

    • @LuonLDC
      @LuonLDC 3 года назад +6

      hey bro, you have to set yVelocity to 0 if controller.IsGrounded == true, it prevents it keep adding velocity even it's touching the ground, hope it helps you

    • @GrtrThnClnD
      @GrtrThnClnD 3 года назад +1

      @@LuonLDC helped me, thanks!

  • @jambreadd
    @jambreadd 3 года назад

    very good tutorial also slow which isn't bad because I don't need to pause the video every millisecond to follow along.
    certainly have a like and sub for me.Thank you!

  • @thiagoferraz5362
    @thiagoferraz5362 4 года назад +1

    You're a life saver!

  • @recino2
    @recino2 4 года назад

    Thank you for this! Liked not just because it's helpful, but because I didn't know about the serialize field thing.

  • @blacky101011
    @blacky101011 3 года назад

    Very helpful, thanks!

  • @suspoocha
    @suspoocha 2 года назад

    well explained... !!

  • @witnnileUnity
    @witnnileUnity 3 года назад

    tebrikler kardeşim

  • @CAESAR_IS_GOD_mohammadisaloser
    @CAESAR_IS_GOD_mohammadisaloser 2 года назад

    do you happen know how to add a 3rd (triple) jump where you can continuosly jump across like in metroid. my only thought was to add an ienumerator and wait a sec(s) to accomplish it? can you delay the next line of code (in Update) so it gives the character time to jump before triple jumping? if I just copy your code and place it below it just hits jump twice basically at the same time is there any way to amend it to keep the original double jump but then have a continuous metroid jump after the 2nd jump? all I did was add the name of multiplier and bool putting canTripleJump and TripleJumpMultiplier.

  • @metalicmoon455
    @metalicmoon455 4 года назад +2

    the madlad is back!

  • @JonTopping
    @JonTopping 2 года назад +1

    I'm having an issue here. When I use move like that, it just warps me to that position, rather than giving me the nice upwards arc as if I've jumped. So gravity still works, bringing the character controller downwards after jumping, but the initial move is just a teleport to a higher position, rather than a jump.

  • @tvrl9180
    @tvrl9180 3 года назад +1

    Thanks dude, this helped a lot!

  • @fshiruba
    @fshiruba 4 года назад

    Thanks for this, this video together with brackeys' third person controller gave me the insight on how to squish a lot of bugs.

  • @seongukpark4165
    @seongukpark4165 3 года назад

    i luv you!!!!! this is what i found! thx you

  • @darabyss9963
    @darabyss9963 4 года назад +1

    Hello i really love your videos, they are simple and get straight to the point, i was wondering if you're going to expand this type of character controller? by adding collisions and camera control

  • @Yavor_Genchev
    @Yavor_Genchev 3 года назад

    thank you this helped me a lot

  • @fredyfred1950
    @fredyfred1950 4 года назад +1

    So cool man

  • @mmr_800
    @mmr_800 3 года назад

    thanks, your video enlighten me!!

  • @kermitthedog_5211
    @kermitthedog_5211 4 года назад +2

    That helped a lot thank you

  • @matius1957
    @matius1957 Год назад

    Hi, jump is working, But i have one problem. Its too fast. When i reduced gravity, jump is higher, not slower. How can I make the jump slower without changing anything in gravity and directionY?

  • @sunce4030
    @sunce4030 3 года назад +1

    I did the same script but my Player falls quickly after moving off of an object.
    Help!!

  • @baslar4258
    @baslar4258 4 года назад

    Its always a helper😇

  • @thenukdevendra1902
    @thenukdevendra1902 4 года назад

    Needed to know if i should use rigidbody or this instead but now i know how to use both

  • @christophermichaelbrooke3677
    @christophermichaelbrooke3677 2 года назад

    How do you get the Character Controller to collide with non-Rigidbody objects? My capsule dude just falls through the floor. It will push Rigidbodies around, but it ghosts through any sort of wall or static object.

  • @biTButter-zz6yg
    @biTButter-zz6yg 4 года назад +4

    Thank you for this, really helped! :DD

  • @frankkubrick865
    @frankkubrick865 4 года назад

    wow thanks a lot for this!

  • @Emilchev
    @Emilchev 2 года назад

    ty mate realy healpfull

  • @justsomedudecalledluqman
    @justsomedudecalledluqman 3 года назад +1

    I need to ask, how do i fix vertical axis not setup

    • @patrickwilliams5231
      @patrickwilliams5231 3 года назад +1

      Make sure Vertical is capitalized when its used in the string. It cannot be lower case or else it will throw that error.

  • @mboe94
    @mboe94 3 года назад +1

    Too bad you aren't using the new input system. Great video though.

  • @YanoeOfficiel
    @YanoeOfficiel 4 года назад

    Thank you helped a lot !:)

  • @mcnuggets_bob1621
    @mcnuggets_bob1621 3 года назад +1

    dude im pretty new but im 50% sure that @ 7:51 instead of making it a serilized feild you could have just changed it to public

  • @storm1us
    @storm1us 3 года назад

    really good video but i have one question, how do i make it so when walking off a platform works with the gravity, right now it's just falling straight down instead of slowly falling.

  • @Massiveboy21
    @Massiveboy21 3 года назад +1

    How do you save the codes for some reason I’m dumb

  • @anhvutv
    @anhvutv 4 года назад

    thanks for help me basic knowlge

  • @devilboy2260
    @devilboy2260 3 года назад

    tysm!!!! your a life saver!

  • @the_real_scar
    @the_real_scar 4 года назад

    Thanks a lot!

  • @SOKOHASEK
    @SOKOHASEK 4 года назад +1

    How can i make the player slightly lose control when they jump?

  • @harryasimellis1134
    @harryasimellis1134 3 года назад +2

    When i put the direction.y -= gravity;
    Line my player goes forward by himself. Does anyone know why?

    • @volybart6637
      @volybart6637 3 года назад +2

      Yep, I have the same problem

  • @uselessgoblin
    @uselessgoblin 4 года назад

    Hi thanks for the vid very nice

  • @bedshitter6946
    @bedshitter6946 4 года назад +1

    Hey, I'm attempting to make a space game. How would I go by making no gravity movements with rotational movements? So like I can go completely upside down and my camera would follow.

    • @DenizSimsek
      @DenizSimsek  4 года назад

      Is it 2D or 3D?

    • @siegervannus7635
      @siegervannus7635 4 года назад

      Look at brackeys tutorial How To Make A Game, I think episode 4, camera follow

    • @ishmil7501
      @ishmil7501 4 года назад

      i think you would stick the camera with your player

  • @katelynbaker1705
    @katelynbaker1705 3 года назад +1

    it always says the associated script can not be loaded.please fix any compile errors and assign a valid script how do i fix this

    • @StrangePerson69
      @StrangePerson69 3 года назад

      Make sure the name of the script is the same as the Monobehaviour class

  • @michaelmyers9061
    @michaelmyers9061 3 года назад +1

    I don't know what to press if I want to jump ( No button is working ). Can you help me because I can't move further? Thanks🔥

    • @alfredothemuscleking
      @alfredothemuscleking 3 года назад

      just press space lmao

    • @alfredothemuscleking
      @alfredothemuscleking 3 года назад

      also he puts "jump" as a place holder. you can put any key in there instead like "space" or "z" or ""y anything as long as you type it right.

    • @DenizSimsek
      @DenizSimsek  3 года назад

      You can check Edit -> Project Settings -> Input Manager to see if there is a key binding for Jump. There should be a default key binding named Jump with Space as its key.

  • @wibiz9657
    @wibiz9657 3 года назад

    Is it possible to remove the character move portion of the script and only leave in the double jump? It's interfering with my animator movement setup.

  • @cuberkid2291
    @cuberkid2291 3 года назад

    i ran into a promblem where when i took the C# script and dragged it to the player it said "the script don't inherit a native class that can manage a script" and i have no idea what that means or how to fix it can someone please help me?

  • @doodledoo5611
    @doodledoo5611 4 года назад +2

    but when i fall it is way too fast, how do i fix this?

  • @portalpig6338
    @portalpig6338 3 года назад +1

    i thought this wouldent work because its 8 months old but it did

  • @GuyNex
    @GuyNex 4 года назад +1

    Thanks man, you're great!

  • @Realmeninvest
    @Realmeninvest 2 года назад

    I keep getting a CS0103: The name ‘_controller’ does not exist? What did I do wrong? I followed your scripted and it does not work.

  • @mreverstrucked23
    @mreverstrucked23 3 года назад

    okay I've had this thing with every script for third person I've tried the controls are inverted

  • @batatadolixo8932
    @batatadolixo8932 3 года назад

    mine is still having mistakes

  • @KitsuraSama
    @KitsuraSama 4 года назад

    eline sağlık çok güzel olmuş. Bir sorum olacak karakter kontrolünü yaptıktan sonra farkettim ki aynı anda 2 yönde ilerleyince( ileri ve sağ örnek olarak) hız iki katına çıkıyor bunu nasıl fixleyebiliriz acaba?

    • @DenizSimsek
      @DenizSimsek  4 года назад +1

      Çok teşekkürler. Bahsettiğin sorunu anladım. Çözüm için direction ve moveSpeed çarpımından sonra normalize metodu kullanılabilir. İlk aklıma gelen bu oldu. Deneme fırsatım olduğunda daha net bir cevap verebilirim. Şimdilik umarım yardımcı olur.

  • @airleks6494
    @airleks6494 3 года назад

    i can jump more than 2 times in a row, can jump in the air permanently, how do i set to jump only 2 times and then have to be on the ground before i can jump again?

    • @hikarirock
      @hikarirock 3 года назад

      Make sure that the if statement Conditions has a boolean state to either true or false then execute have the oppsites of that.

  • @goodchum8229
    @goodchum8229 3 года назад

    Does this apply to first person or only to third person games? I tried to use this in my first person game and it is not working. I think it has something to do with the camera moving, but the character still responding to the commands in the way it is programmed to. For example, I can face to the left and press W, but this would make me to into the right. Can anyone tell me how to solve this, I am new to Unity.

  • @SOKOHASEK
    @SOKOHASEK 4 года назад +1

    And my player falls too fast only when they walk off a plane Help me!

    • @buffalo5357
      @buffalo5357 4 года назад

      Uh if it falls it does that and that mean it has gravity

    • @sunce4030
      @sunce4030 3 года назад

      @@buffalo5357 How to fix it

    • @grindx1292
      @grindx1292 3 года назад

      @@sunce4030 lower the gravity

  • @harharrr9810
    @harharrr9810 8 месяцев назад

    after i implement it my character start floating

  • @mamtapatil1892
    @mamtapatil1892 2 года назад

    how to rortate

  • @kylekrb1
    @kylekrb1 3 года назад

    When I put this in, for some reason it moves me on the X axis rather than the y, I can't figure out why.

    • @BBlenderology
      @BBlenderology 3 года назад

      I think you can change the location of x and y in coding. like x 1 bla bla y 2 bla bla = y 1 bla bla bla ...

  • @hakkukhadka198
    @hakkukhadka198 4 года назад

    Please make on video on fps controller

  • @a_exi7285
    @a_exi7285 3 года назад

    4:40 name of this app?

  • @arifcemselcuk4170
    @arifcemselcuk4170 4 года назад

    Thank you mate. It's very simple method. Devamını bekliyoruz. Can you show us Third Person Jump while running with animation?(like mixamo characters). Abone olundu bildirim açıldı.

  • @matheuscavalcante5711
    @matheuscavalcante5711 4 года назад

    The gravity with controller.move does not work with me, here i have to use controller.SimpleMove instead

  • @baronedits2213
    @baronedits2213 3 года назад

    i haw a bug when i am going to forward and i am turning my camera in the game i am loking my foeward but cube going rearward

  • @uselessgoblin
    @uselessgoblin 4 года назад

    why are there underscores in there code?

    • @BobrLovr
      @BobrLovr 3 года назад

      it's called _snakeCase. It's just a naming convention people use usually for private variables, then camelCase is for public variables.
      You don't have to do it, some people just like to organize it that way.

  • @brhvoicu
    @brhvoicu 3 года назад

    1:24 It's not a capsule it's a BEAN

  • @Elmarath
    @Elmarath 3 года назад

    ağzına sağlık

  • @crazegamez290
    @crazegamez290 4 года назад

    direction.y is causing a bug like it doesn't exist lol any idea what else i can use trying to merge it with my own script ignore the player bit im trying to see if it works by tag
    using UnityEngine;
    public class charactercontroller1 : MonoBehaviour
    {
    public Rigidbody rb;
    public Rigidbody rb2;
    [SerializeField]
    public float speed = 4f;
    public float rotationspeed = 80;
    float rot = 0f;
    [SerializeField]
    public float gravity = 8;
    Vector3 moveDir = Vector3.zero;
    private Vector3 Jump;
    public float jumph;
    [SerializeField]
    public float jumpforce = 3.5f;
    CharacterController controller;
    Animator animator;
    // Start is called before the first frame update
    void Start()
    {
    Jump = new Vector3(0f, jumph, 0f);
    controller = GetComponent();
    animator = GetComponent();
    }
    // Update is called once per frame
    void Update()
    {
    Player.Position.y -= gravity;
    if (controller.isGrounded)
    {
    if (Input.GetKey("w"))
    {
    animator.SetInteger("condition", 1);
    moveDir = new Vector3(0, 0, 1);
    moveDir *= speed;
    moveDir = transform.TransformDirection(moveDir);
    }
    if (Input.GetKeyUp("w"))
    {
    animator.SetInteger("condition", 0);
    moveDir = new Vector3(0, 0, 0);
    }

    if (rb.velocity.y == 0)
    {
    if(Input.GetButtonDown("Jump"))
    {
    Player.Position.y = jumpforce;
    }
    }
    }
    rot += Input.GetAxis("Horizontal") * rotationspeed * Time.deltaTime;
    transform.eulerAngles = new Vector3(0, rot, 0);
    moveDir.y -= gravity * Time.deltaTime;
    controller.Move(moveDir * Time.deltaTime);
    }
    }

  • @BobrLovr
    @BobrLovr 3 года назад +1

    16:06 you could just use an else if statement haha, don't have to put and if inside an else clause.

  • @jonathanboiragee3347
    @jonathanboiragee3347 4 года назад

    does not work
    errors appear here the errors
    Assets\scrpts\Movement.cs(12,58): error CS1002: ; expected
    Assets\scrpts\Movement.cs(7,44): error CS1519: Invalid token ';' in class, struct, or interface member declaration
    Assets\scrpts\Movement.cs(7,33): error CS1002: ; expected
    heres the code
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Movement : MonoBehaviour
    {
    Private CharecterController _controller;
    // Start is called before the first frame update
    void Start()
    {
    _controller = GetComponent()
    }
    // Update is called once per frame
    void Update()
    {

    }
    }

    • @mmitchell10000
      @mmitchell10000 3 года назад +2

      This happens to everyone, beginners and advanced programmers...
      The line... _controller = GetComponent() ... needs a ";" at the end of the code.

  • @finnysabu520
    @finnysabu520 4 года назад

    that gravity is not working

    • @nikmati7930
      @nikmati7930 4 года назад

      I just fall from the edges like a giant rock

  • @Stormsson
    @Stormsson 4 года назад

    Why at 14:41 both directionY at line 36, and the vector at line 40 are multiplied by Time.deltatime? isn't enough to apply in one row OR the other?

  • @TheChampionBlack
    @TheChampionBlack 4 года назад

    Hey dude!
    When I write the script it gives me an error and it says
    "Error CS1061 'ThirdPersonMovement' does not contain a definition for 'moveDir' and no accessible extension method 'moveDir' accepting a first argument of type 'ThirdPersonMovement' could be found (are you missing a using directive or an assembly reference?)"
    How can I fix this?

    • @DenizSimsek
      @DenizSimsek  4 года назад +1

      Did you create a variable called moveDir inside the script?

    • @TheChampionBlack
      @TheChampionBlack 4 года назад

      @@DenizSimsek Well I did create a "float moveDir" or something like that a week ago to try and see if I can fix it and the error went away but the dash didn't work...
      Propably did it wrong lol
      So how should I do it?

    • @TheChampionBlack
      @TheChampionBlack 4 года назад

      @James Thwaites Thanks but I have already fixed it XD

    • @TheChampionBlack
      @TheChampionBlack 4 года назад

      @James Thwaites Thank you a lot but I am really just messing around and learning stuff right now...
      It's really to early for me to say that I will make a game so I am just collecting skills and knowledge!

    • @TheChampionBlack
      @TheChampionBlack 4 года назад

      @James Thwaites Understandable!
      I agree with everything you said but I just need a little more practice but nonetheless...
      Thank you for your motivational words!
      Also timed dash?
      You mean dashing with cooldown where you can't spam it?
      Can you maybe show me that code chief 👀?

  • @thatdev571
    @thatdev571 4 года назад

    Sorry it didnt work

  • @justanothercc
    @justanothercc 4 года назад

    why is my life such a failiure?
    i tried about 6 character controller videos in unity and NONE OF THEM work.
    i've spent days of my life trying to become a programmer and i always fail

    • @DenizSimsek
      @DenizSimsek  4 года назад +3

      You spend your time learning Unity and programming. You are already cooler than many people I know. Try to look at the learning phase as a continuous improvement. You are not becoming anything, you’re just getting better and better.
      If something doesn’t work, try to relax for a bit. Maybe do something else. And then try to understand where is the problem. Think about what your are trying to do, then how you are trying to achieve it. Read the code line by line and try to reason the output.

    • @justanothercc
      @justanothercc 4 года назад

      @@DenizSimsek thanks =D

    • @BobrLovr
      @BobrLovr 3 года назад +1

      @@justanothercc enjoy the failure, even senior devs often feel like they have no clue wtf they're doing. If you think that there's ever a point where things work the first time you're wrong. Being a programmer is just becoming a professional problem solver/debugger. If you don't like that find something else to do

  • @onx99
    @onx99 4 года назад

    Its not helpful to watch a 20 minute video full off errors that have to be fixed before the code will work.

  • @abdelrahmanammar1633
    @abdelrahmanammar1633 2 года назад +1

    when i press space the player doesn't jump, i wanna know what is the problem