3D Platformer in Unity - Player Controller (Part 1)

Sdílet
Vložit
  • čas přidán 26. 06. 2024
  • A Unity 3D Platformer is a challenging project! In this first episode, we will tackle building the foundation of our game by creating a Player Controller, harnessing the full power of the new Unity Input System and building a custom Camera Manager to work with Cinemachine. A few surprises are inside, but you'll have to watch to find them! (Some of them are also in the source repository!) Code along with me and lay the groundwork for getting into more programming patterns and game architecture in future episodes!
    🔔 Subscribe for more Unity Tutorials / @git-amend
    #unity3d #gamedev #indiedev #3dplatformer
    ▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
    0:00 Intro
    0:30 Project Setup
    5:00 Handling Input
    11:19 Player Controller
    19:50 Camera Manager
    24:00 Animation
    27:00 Demo and Outro
    Source code: github.com/adammyhre/3D-Platf...
    JetBrains Articles Mentioned In This Video
    blog.jetbrains.com/education/...
    www.jetbrains.com/rider/nextv...
    Open Source Used In This Video
    github.com/KyleBanks/scene-re...
    Assets Used In This Project (Affiliate Links)
    Dungeon Mason Tiny Hero Duo: (FREE): assetstore.unity.com/packages...
    MeshTint Burrow (FREE): assetstore.unity.com/packages...
    Cartoon Remaster VFX (FREE): assetstore.unity.com/packages...
    Casual Game SFX (FREE): assetstore.unity.com/packages...
    Ultimate Low Poly Pack: assetstore.unity.com/packages...
    DOTween (FREE): assetstore.unity.com/packages...
    DOTween (Pro): assetstore.unity.com/packages...
    Follow me!
    linktr.ee/gitamend
  • Hry

Komentáře • 54

  • @git-amend
    @git-amend  Před rokem +15

    Hi everyone! There's a small bonus in the first few minutes! Click the LIKE button if you find it useful!

  • @ewwitsantonio
    @ewwitsantonio Před 7 měsíci +7

    Can't believe I've never thought to automate the creation of the same folder structure I create EVERY time. HELLO! Haha. Thank you. I think I'll be learning a lot from you!

    • @git-amend
      @git-amend  Před 7 měsíci +1

      Haha, sometimes the simplest solutions are the ones we overlook! Nice to have you here!

  • @STARmod
    @STARmod Před rokem +1

    Perfection, hyped for the series!

  • @AaronAsherRandall
    @AaronAsherRandall Před 8 měsíci +5

    Just, wow! My jaw dropped when you created the Setup tool in the beginning! Please continue this series, it's amazing!

    • @git-amend
      @git-amend  Před 8 měsíci +3

      Haha! The setup tool gets more powerful in future episodes! Glad you like it.

    • @orpheuscreativeco9236
      @orpheuscreativeco9236 Před 4 měsíci

      ​@@git-amendSeriously dope 👍 Thanks for sharing your experience and knowledge with us ✌️✨

    • @git-amend
      @git-amend  Před 4 měsíci

      @@orpheuscreativeco9236 Thanks!

  • @s.w.e.d.3057
    @s.w.e.d.3057 Před 3 měsíci +1

    hidden gem channel. been doing Unity for 6 years now and the first 2min 30seconds are enough to show this guy aint messing around

    • @git-amend
      @git-amend  Před 3 měsíci

      Hey! Thanks for the kind words!

  • @maxrandolph5437
    @maxrandolph5437 Před 5 měsíci

    Love this series so far... looking forward to the next one. I learned alot of editor and design concepts in a very short time :)

    • @git-amend
      @git-amend  Před 5 měsíci

      Glad you like them! Cheers!

  • @CyberStudios
    @CyberStudios Před 6 měsíci +1

    🎉 absolutely amazed at this channel! Have yet to find something similar!! Keep it up. :D

  • @andywatts
    @andywatts Před 4 měsíci +1

    Thanks for sharing. Really great to see game-wide design patterns from an experienced hand..
    I'm gonna steal the setup script and input scriptable object. :)

  • @Wellyngton-rm3bb
    @Wellyngton-rm3bb Před 11 měsíci

    Awesome tutorial!

  • @brodgers123
    @brodgers123 Před 11 měsíci

    Good job, earned my sub.

  • @tianqigao869
    @tianqigao869 Před rokem

    awesome tutorial!

  • @bino6251
    @bino6251 Před rokem

    you are so awesome

  • @hydroweapon
    @hydroweapon Před 4 měsíci

    That setup script thing was awesome

    • @git-amend
      @git-amend  Před 4 měsíci +1

      Glad you liked that one!

    • @hydroweapon
      @hydroweapon Před 4 měsíci

      the C# I know is all in-game related so it was refreshing to see something like that@@git-amend

  • @jukka-pekkalyytinen6558

    I'm curious what sort of input are you using? What I keep hearing doesn't sound like a keyboard :D I appreciate the tutorials, I'm picking up a very professional vibe compared to a lot of other creators.

    • @git-amend
      @git-amend  Před 6 dny

      It's just a mechanical keyboard. In later videos you won't hear it at all because I started using Krisp AI for noise cancellation. Thanks for watching!

  • @meharofficial4284
    @meharofficial4284 Před 7 měsíci

    Please do complete this series I am loving it and need help till end

    • @git-amend
      @git-amend  Před 7 měsíci +1

      There is no 'end' per se, each series lasts as long as subscriber interest stays high. If you need help with a specific game mechanic however, let me know and perhaps it can be the subject of a future video!

  • @jeremyruizM42
    @jeremyruizM42 Před rokem +1

    A 3D platformer series is nice, but what about the rail shooter? Is it finished? I want to add more to mine but I'm unsure of what to prioritize. What would you have added?

    • @git-amend
      @git-amend  Před rokem +1

      Unfortunately for the Rail Shooter, not too many people watched the last video in that series.
      While all the core mechanics are done, I can think of 2 things that you could add to your own version: obstacles/pickups (things to collide with) and a UI/HUD. These topics were also covered in the Shoot 'Em Up game as well, which would be very similar.

  • @Fitz0fury
    @Fitz0fury Před 4 měsíci

    Quick note for those who may not use git: you may need to restart PC after installing even if git is running on your machine. According to the unity doc you only have to close out and restart the project and unity hub. that didn't work. i confirmed version and service before starting back up unity but it still didn't allow me to install from git. had to reboot the machine.

  • @ekekw930
    @ekekw930 Před 3 měsíci

    Hey! Great video once again. For some reason my ScriptableObject InputReaders OnEnable method doesnt get called and thus I have no input. I does get called when the scripts recompile however. Any idea?

    • @git-amend
      @git-amend  Před 3 měsíci +1

      One thing to keep in mind with instances of ScriptableObjects is that Unity does call OnEnable on ScriptableObjects after scripts are recompiled because it reloads the assets, which triggers the method.
      However, the method should also be called when you run the game. Make sure that is happening.
      The next thing to check is that your PlayerController is actually enabling the input actions by calling the InputReader.EnablePlayerActions() method from Start.

  • @marc8150
    @marc8150 Před měsícem

    I’ve got another question, my char is not moving and I have no idea why because I’m pretty sure he should^^
    This might gonna be a long comment:
    
At this point we mainly use the Direction expression bodied Property (in the InputReader class) to get the X and Y values when we move the character via WASD. This input gets then processed in the moveDirection local variable in the HandleMovement Method in the PlayerController. This is already a problem in my case, since no matter what I press while logging I always get (0,0,0) in return. Which should not be the case because in other projects the exact same way of getting the input does work fine.
    If I am correct the UnityAction Move while being invoked from the OnMove, is doing basically nothing right not since nothing is subscribed to Move. OnMove on the other hand is subscribed to the Callbacks of the Action Map and therefor should at least fire when we hit WASD (which it doesn’t in my case) and if I log it I should receive a comment in the Console. Which I currently don’t get as well.

Is my thinking correct or am I wrong here? I really have no idea anymore why it does not work
    If you somehow manage to find some time and you want to look into this, here is a Google Drive Link to the project: drive.google.com/file/d/1_b-lVptEG_ygqWFFNr4nv6rBJkgpjk4f/view?usp=sharing
    Have a good rest of the weekend :)
    Edit: Okay this is super weird. I just went and put a Movement Property and a PlayerInputActions instance into the PlayerController and that worked. Then I noticed I was still logging the Movement from the InputReader class and that worked too, so I removed everything I implemented before and without changing anything, now everything is working fine. I can't believe it man, this is satisfying and unsatisfying at the same time because I still have no idea what was causing the error... Well at least I can progress now :D

    • @git-amend
      @git-amend  Před měsícem

      Normally I do not have time to download and debug projects. However, I did download yours and opened it on my PC using Unity 6.000.0.1f1 - and the character moves around fine without having changed anything.
      I can only suggest a few things. 1) Do a complete Reload of your project by going to the top menu and selecting Assets > Reimport All. This will reimport all packages and assets in your project as if they are new. 2) Start debugging. Break it down bit by bit starting with the Player Input system until you find the source of the issue. 3) Eliminate the possibility that your hardware is the problem.

    • @marc8150
      @marc8150 Před měsícem

      @@git-amend Wow thanks for the effort!

  • @marc8150
    @marc8150 Před měsícem

    Hey, I started the series since I really liked the State Machine video. I've run into a problem tho, Since the last update of the Cinemachine the FreeLook Camera class is deprecated. At least that's what it says on the tooltip. You get told to use the CinemachineCamera instead. This however makes it impossible to select either the X or Y m_InputAxisValue which are solely members of the CinemachineFreeLook class.
    So the question is should I just use the CameraFreeLook or do you know a way to make it work with the CinemachineCamera class? (This is regarding the Camera Manager class at 19:51).
    PS: Oh and I am using the new Unity 6 preview version which could be a problem too I guess (but I think it should be fine, since the Cinemachine is a standalone package, right?),

    • @git-amend
      @git-amend  Před měsícem

      That's a very interesting question - actually I have on my TODO list for today is to walk through the new Cinemachine 3.1.0 Samples and find out what's changed and improved. I'll get back to you on this.

    • @marc8150
      @marc8150 Před měsícem

      @@git-amend Cool, thank you very much! :D

    • @git-amend
      @git-amend  Před měsícem

      Check out this page, it basically outlines everything I would advise: docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/FreeLookCameras.html

    • @isaacj.p.7657
      @isaacj.p.7657 Před 8 dny

      @@git-amend It seems that to manually change values with the new version of cinemachine you have to get the CinemachineInputAxisController component which references the axis in an array. Unfortunately the InputValue of each axis appears to be the only value that you can't simply write to.
      Example syntax is CinemachineInputAxisController.Controllers[0].InputValue = cameraMovement.x * multipliers However, this doesn't work and I'm at a loss as to why.
      Controllers[0].Enabled = false works though so I may have to just switch the axis on and off when we enable/disable mouse look.
      Did you have any other insights when you looked into the new version?
      Fantastic videos by the way, thank you very much.

    • @git-amend
      @git-amend  Před 8 dny

      @@isaacj.p.7657 I don't have any great insights into that in particular, but I would suggest adding a layer of abstraction if you need to write to that axis array.

  • @sk8ersrok366
    @sk8ersrok366 Před 3 měsíci

    What IDE do you use?

  • @jamestanubrata6782
    @jamestanubrata6782 Před měsícem

    How do you do when doing an animal controller

    • @git-amend
      @git-amend  Před měsícem

      Actually I use Malbers Animal Controller from the Asset Store for that, it's excellent.

  • @blazingpotato642
    @blazingpotato642 Před rokem +1

    do you have a discord server?

    • @git-amend
      @git-amend  Před rokem +3

      Not an official one yet, something to consider!

  • @Laura-po9mw
    @Laura-po9mw Před 3 dny

    Thank you a lot for this videos, they've helped me a lot. Anyways i wanted to use the Rebind system from InputSystem, how could I implement this without breaking up the InputReader script? I know I need to replace the
    HeroInputActions inputActions;
    for
    PlayerInput inputActions;
    Since the Rebind system uses the Player Input (you bind the HeroInputActions into it) but then everything else stops working. The only change that I manage to make it work is
    public Vector3 Direction => inputActions.Player.Move.ReadValue();
    for
    public Vector3 Direction => playerInput.actions["Move"].ReadValue();
    but for the rest of the events I can't manage to make them work 😥 if anyone could help it would be amazing.
    Thanks a lot and sorry if it is something easy to solve, I've been looking how to do this for days and I'm stucked 😅

    • @git-amend
      @git-amend  Před 3 dny +1

      I think this is a question you'll potentially get more help on Discord with than in the comments - there's a link in the 'About' section of the channel.

    • @Laura-po9mw
      @Laura-po9mw Před 3 dny

      @@git-amend Thank you! I'll ask around 😊