How to Check if Your Player is GROUNDED Unity Tutorial

Sdílet
Vložit
  • čas přidán 9. 04. 2020
  • How to check if your character is standing on the ground! Also we cover checking WHAT your character is standing on, as well as calculating slope angles and using that data to affect your character's movement.
    This is part two of the How to Make a First Person Controller in Unity series. What would you like the next part to be about? Leave a comment and let me know.
    Thanks for watching!
    -----------------------------------------------------------------------------------
    JOIN THE DISCORD SERVER!
    / discord
    -----------------------------------------------------------------------------------
    SUPPORT THE CHANNEL
    The easiest way to support the channel is by liking, subscribing, and sharing. But if you want to go that little bit further, sign up for my Patreon at; / b3agz
    All Patreons get access the Patreon-exclusive Discord channel in our server, as well as the show notes from each video. These are annotated code snippets that I use to remind me what I'm doing when I record...
    -----------------------------------------------------------------------------------
    LINKS
    Script from the video; github.com/b3agz/quick-bits/b...
    -----------------------------------------------------------------------------------
    SOCIAL STUFF!
    Website: b3agz.com
    Twitter: / b3agz
    Instagram: instragram.com/b3agz
    #MadeWithUnity #UnityTutorial #GameDev
  • Hry

Komentáře • 30

  • @kisstepan1996
    @kisstepan1996 Před 3 lety +1

    Man, just thank you so much! Been looking for a raycast decision for 2 days and absolutely broke my head of the wall. Thank you sooo much!

  • @SoraBorg
    @SoraBorg Před 4 lety +23

    I can already see an exploit here. The speed change is being calculated based on the slopeAngle, which itself is dependent on direction. This means that a player walking backwards up a slope would move faster.

    • @mrkoix2398
      @mrkoix2398 Před 3 lety +11

      this is intentional for speedrunners obviously.

    • @forcepower7116
      @forcepower7116 Před 3 lety +1

      How would you fix this

    • @nullfloofyboi8254
      @nullfloofyboi8254 Před 3 lety +4

      this is not a bug it is a... FEATURE! yeah we all obviously want this for speedrunning and we are TOTALY not trying to avoid more debugging. psh who would do that!

    • @bluemodize7718
      @bluemodize7718 Před 2 lety

      @@mrkoix2398 😂

    • @berka5526
      @berka5526 Před 2 lety

      Did you just discover B hopping in half life?

  • @theandyd1972
    @theandyd1972 Před 4 lety +2

    Really excellent explanation as always, thanks so much for taking the time to run through this and break it down. You are really helping me out a great deal get to grips with Unity and code around generating these game types. Keep up the great work and why so many views but so few likes, come on guys support click that like Button !

  • @10gbo_pizza
    @10gbo_pizza Před 3 lety

    this was really helpful! thanks!

  • @Zicrus
    @Zicrus Před 4 lety +7

    Use the direction the player is trying to move to calculate the speed rather than the way you are facing. Otherwise, you can run uphill really quickly if you walk backwards.

  • @itsleasy1604
    @itsleasy1604 Před 3 lety

    Omg ty soooo much for this. i almost gave up on this.

  • @LilYet
    @LilYet Před 4 lety

    thank you so much man, i spent all day trying to do this and i couldn't, i was watching a vid from Brackeys, and when i used your vid i got it first try. this is a way better video then brackeys not even joking

  • @M3RS.
    @M3RS. Před 4 lety

    I just found your channel and I liked the crosshair video and this one since it told me how to do the thing I wanted which is being slowed down on slopes. It was hard to find a tutorial for that.
    Can I ask if you could consider these stuff for the next tutorials?:
    - Crouching under objects and standing up will not push you out from under it (meaning you will stay crouched under the object when the crouch button is released)
    - You slow down when crouching (tutorials from big CZcamsrs like Brackeys did not bother with this)
    - Crawling (you are completely on the ground and are even slower then crouching)
    - Jump or sprint out from crouching position (when crouching pressing Shift for sprint and W for forward you will uncrouch and start to sprint or start jumping with the Spacebar)

  • @cameron7howell
    @cameron7howell Před 4 lety

    Wonderful tutorial. The only issue I am still having with this and the one in the Minecraft series, is you can flip the camera upside down. Any chance of a quick part 3 for that? I know you mentioned you were going to compile a bunch of small things but yea, that would be something SUPER beneficial!

  • @hannesennemann6303
    @hannesennemann6303 Před 2 lety

    Thanks, you helped me allot.

  • @kryniu2181
    @kryniu2181 Před 3 lety

    rly helpful

  • @Zicrus
    @Zicrus Před 4 lety +4

    Use spherecast instead of raycast, because with raycast, the ground needs to be directly below the center of the player. With spherecast you can still jump if you are on the edge of a cliff.

  • @Rovsau
    @Rovsau Před 2 lety

    Bookmarked this video under #gold

  • @FireHawkX
    @FireHawkX Před 2 lety

    I was really hoping you would solve the character "bouncing" down the slope when going too fast down...
    Otherwise, really great ideas and suggestions! :)

  • @ruchirraj5300
    @ruchirraj5300 Před 3 lety +2

    This implementation has a lot of limitations and bugs for it to be implemented in an actual game,
    The only place I maybe would use such a basic implementation is a game like minecraft, even in that it won't work in 60% of the cases, for ex, on ledges or on steep slope

  • @nightnoodlespeedruns
    @nightnoodlespeedruns Před 3 lety +1

    after 30 minutes of frustation i found out that for some reason visual studio automatically corrected transform to _cameraTransform XD

  • @GuillemPoy
    @GuillemPoy Před 4 lety

    What about stairs? How would you do a character controller with a rigidbody properly wotk with stairs?

    • @lubu682
      @lubu682 Před 3 lety

      Character controller is best for stairs. or you could do a raycast on the feet and just above them.

  • @Ruptured_AU
    @Ruptured_AU Před 2 lety

    Was going nutz in the first 5 minutes because that raycast was not working on terrain. Put a box under my player and it suddenly worked. How can I make this work with the terrain?
    EDIT: Its actually not working when the terrain is flat.

  • @cahydra
    @cahydra Před 4 lety

    how does it not know that the player is grounded

  • @SDFTDusername
    @SDFTDusername Před 4 lety

    hi early!

  • @taleofrealitydeveloper2147

    Can you check out my game? Thanks