3D Platformer in Unity - Player Controller (Part 1)
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
Hi everyone! There's a small bonus in the first few minutes! Click the LIKE button if you find it useful!
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!
Haha, sometimes the simplest solutions are the ones we overlook! Nice to have you here!
Perfection, hyped for the series!
Just, wow! My jaw dropped when you created the Setup tool in the beginning! Please continue this series, it's amazing!
Haha! The setup tool gets more powerful in future episodes! Glad you like it.
@@git-amendSeriously dope 👍 Thanks for sharing your experience and knowledge with us ✌️✨
@@orpheuscreativeco9236 Thanks!
hidden gem channel. been doing Unity for 6 years now and the first 2min 30seconds are enough to show this guy aint messing around
Hey! Thanks for the kind words!
Love this series so far... looking forward to the next one. I learned alot of editor and design concepts in a very short time :)
Glad you like them! Cheers!
🎉 absolutely amazed at this channel! Have yet to find something similar!! Keep it up. :D
Wow thanks!
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. :)
Glad it was helpful!
Awesome tutorial!
Glad you liked it!
Good job, earned my sub.
Awesome, thank you!
awesome tutorial!
Thank you! Cheers!
you are so awesome
That setup script thing was awesome
Glad you liked that one!
the C# I know is all in-game related so it was refreshing to see something like that@@git-amend
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.
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!
Please do complete this series I am loving it and need help till end
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!
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?
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.
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.
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?
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.
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
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.
@@git-amend Wow thanks for the effort!
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?),
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.
@@git-amend Cool, thank you very much! :D
Check out this page, it basically outlines everything I would advise: docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/FreeLookCameras.html
@@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.
@@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.
What IDE do you use?
JetBrains Rider
How do you do when doing an animal controller
Actually I use Malbers Animal Controller from the Asset Store for that, it's excellent.
do you have a discord server?
Not an official one yet, something to consider!
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 😅
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.
@@git-amend Thank you! I'll ask around 😊