Amazing video and helped me understand how the new input system works, but i'm having some issues with my player character constantly going up in the air. I can move around and turn but it seems like he is constantly jumping up into the sky. what could be the issue?
@@OneWheelStudio well, I saw it and already made the change but that still makes the character float upwards constantly. I even tried copy paste the one from your github, but it still has the issue.
@@OneWheelStudio nevermind, I found out what the issue was. the issue was that I had the capsule collider as a trigger. which for some reason made it the character go up into the air.
For anyone using Unity version 2021.2.4f1 or higher, in order to select "Add 2D Vector Composite", you need to change the Action Type to "Value" and the Control Type to "Vector 2" in the Action Properties, then you can press the plus sign and it will be called "Add Up/Down/Left/Right Composite".
This is great! So far the best video I found showing how to implenment the new Input System, Cinemachine, Animation and putting it altogether. Instead of a series of videos in a long tutorial, I really dig this relatively short form. p.s. the timestamps are really helpful too, thank you.
This type of videos where you can actually see the bigger picture and the architecture of making games, but at the same time you cover every component and technique that makes up that bigger picture. Big thanks!
For anyone not finding creating "input actions", you need to install the input system from your package manager before the first step in this tutorial.
I appreciate you for putting this out. I've been stuck in a lot of weird/bad habits for making controllers, using animator and barely understand the input system and this made it all so much clearer for me, even without following along directly.
24:37 You can find the animation inside the objects. So click drop down for the object, fbx or whatever it is, and drag the animation from inside of it into the inspector. Great tutorial!
I love this style of videos, keep up the great work! It feels like a one on one tutoring session and that makes walking through the codes and around Unity all that much easier! Thank you for making great videos!
I have been watching a lot of Unity tutorial videos trying to get a better understanding of both the new Input System as well as being able to better understand Unity with creating my game and I have to say this has to be the most helpful and beginner friendly tutorial I have seen, and it really allowed me to better understand how to work with creating a character controller. Thank you so much for making this video it has helped me tremendously get better at making my own games!
You are by far the best instructor I've ever seen, thanks for the hours you take to make and upload these videos, you make my life so much better after dealing with learning frustration as a noob in Unity. THANK YOU!
Thank you so much! You helped me a lot. I'm new with Unity and C# but after this video I made big steps forward with my project and skills. One step at a time :) More videos like this and I would like to see long video where we could make full game from start to finish.
I have been trying to wrap my head around this new input system and thanks to you, I think I about have a grasp on it. Thank you for your time and effort. Liked and subbed.
Excellent tutorial! Thanks very much. I don't normally comment on many tutorials but felt I had to in this case. I really like your approach and feel that you've helped me take my understanding of Unity character controlling and physics to the next level. Cheers and keep up the great work. ;-)
The NEW way to set up the 2d Vector is as follows :( Click on Move Go to Binding Properties and select "Action Type: Value" then "Control Type: Vector 2" THEN you can right click Move and Add Up/Down/Left/Right Composite will show up. It will then add a 3d vector to your drop down for WASD. So stupid of them to switch that up
Hey really liked this kind of style of video, very informative, learned a lot. But when you were explaining the movement physics was a bit confusing, maybe do a separate video where you explain this better ?
That’s a fair critique! My day job is a physics teacher so easy to gloss over bits when I’m focused on the code. Was there something in particular about the physics that was unclear? Or all of it? 😛
@@OneWheelStudio This video was was about unity new Input System and boy it delivered. I think it's more a request/suggestion than a critique :D yeah to me physics and math is unity is the bigger hurtle. I do understand them when I get explained, but figure this out by my self or where to start is what melts my brain. Cheers
I found out how to get the jump to work for me! I created a new private float at the top and named it "RayRange" and set it to 1.25f After that, I went down to the private bool IsGrounded() function and changed it to the following: private bool IsGrounded() { Vector3 direction = Vector3.down; Ray ray = new Ray(this.transform.position, transform.TransformDirection(direction * RayRange)); if(Physics.Raycast(ray, out RaycastHit hit, RayRange)) { return true; } else { Debug.Log("not grounded"); return false; } } Hope this helps some folks!
I have some weird issue. The code is the same, and the actions are as well. I checked; the camera is attached, and there are no errors. But my character moves only if I press A and D, and it moves diagonally (kinda). I have no clue why W and S don't work. I will try to fix this, but it seems like I wasted 2 hours on this. In the end, I might just go back to the old version of moving the character because I have no idea at all what the issue might be.
Wait, doesn't the current melee code let player spam attack? Animation will play fine but if we were to put damage mechanic, player would be able to do damage several times during animation just by pressing attack constantly.
Not exactly, but the solution shown also isn't pefect. As shown the player can press the button once and the animation will run and if they press the button again the trigger will get set and when the melee animation finishes it will immediately play again. To resolve this you could check the which animation is playing. You could also dive in to Animation State Behaviors which allow really good control/knowlege of the animation state. Check Animation: www.reddit.com/r/unity_tutorials/comments/owryhj/3rd_person_controller_new_input_system/ Unity Animatin State Behavior: docs.unity3d.com/ScriptReference/StateMachineBehaviour.html
I have this error. I have done everything as the video. No i didnt type the code in ondisable to onenable. Null reference exception: Object reference not set to an instance of an object ThirdPersonController.FixedUpdate()
NRE: Object ref is normally because something is not being linked together, go through your code, and your hierarchy and make sure you link everything that should be, i.e make sure your camera is linked. Small tip, it's really hard for someone to help you when we can't see your code, 98% of the time it's a typo. Try pasting your code into a reply message and someone might be able to spot the problem.
For anyone who couldn't get the jumping to work , modify your isGrounded function as follows , and create a layer of your choosing and give it to the object you're using as floor , and it should work private bool IsGrounded() { float rayLength = 0.3f; Ray ray = new Ray(transform.position + Vector3.up * 0.1f, Vector3.down); int layerMask = LayerMask.GetMask("INSERT LAYER NAME HERE"); if (Physics.Raycast(ray, out RaycastHit hit, rayLength, layerMask)) { return true; } else { return false; } }
you cannot drag those animations because they have meshes included those are full animation files with mesh pieces included if you opened the animation that you said "I can't drag these into the animation slots" and you selected the animation file specifically then dragged it into the blend slot it would work. I had the same question I was like why can you not drag this into the blend state but that is because that is the entire mesh and not just the animation data
This is very cool. Would you please do a tutorial to show how to combine melee animation with the third person from the starter assets? The code seems to be different. Thanks for this video! :)
No, not really. But I think you can combine Mixamo animations and the starter assets. So you could parent a sword to the hand? But I'm not sure about this.
@@juliaalder2007 If you find anything on that then please tell here. And also in this tutorial when I press the W key , the player directly runs from idle when he should just walk. Can you tell how to fix it?
One point to square roots calculation in general. This isn't slower anymore most compiler these day can do it in 1 cpu clock cycle. It cant get any faster then this. :)
HEY! Thanks for the Tutorial! i had an issue with the character, one that made her fly as soon i started the game. It wasnt the code error in 16:32 and it wasn't a capsule collider issue, i find out that this is a problem with the Animator component... to fix this, just disable Apply Root Motion. Hope someone find this useful, thanks for the video
Why do we only multiply the jump descent by Time.fixedDeltaTime isn't everything in FixedUpdate frame rate independent? Also, curious why you choose not to use a CharacterController?
Okay I fixed the missing thirdpersonactionsasset by RENAMING my inupt settings thingy, but I still don't know what to rename RIGIDBODY? I'm using a different unity asset character than yours called Insect4_Green. Do I rename that character to RIGIDBODY? It also has a sub thingy called Body_LP.
I'm commenting before following the video, but just by passing my eyes on it, it seens that this is the perfect tutorial for everything i planned to use, so thanks a lot in advance
@@OneWheelStudio Yeah, there are a some tweaks to make (e.g., my move is 2d simple directional, with backwards and sideways specifics animations), but in general a very very solid tutorial, i learned a lot! =DD
what does it mean this ?where can i get ThirdPersonActionsAsset ? Assets\Scripts\ThirdPersonController.cs(10,13): error CS0246: The type or namespace name 'ThirdPersonActionsAsset' could not be found (are you missing a using directive or an assembly reference?)
That means it can't find the class/script in your project. Did you generate the C# class from your input action asset? If you have other errors that are preventing compilation that could be a problem too - if there aren't any other errors then don't worry about this.
Amazing video and helped me understand how the new input system works, and can u make tutorial how to make so that when i click control when player moves this player slows down and goes on walk animation
Hey @One Wheel Studio I dont know how to get when the mouse button down for example, could you help me, because I need set an animation for an action that need hold the button down
I have a different question. If I wanted to use a 2d directional animator (for example to make the character able to strafe to the sides with animations) then how would I use that with the new input system?
I'm not sure it's any different with the new input system. Maybe I'm wrong. So here's my first thought on the problem: You would need to separate out the side to side velocity and the forward/backward velocity - these would need to be relative to the camera's direction. You could look up "vector projections" to project the character velocity onto the camera's direction to get the velocity in the s/s or f/b direction. From there you could then send the magnitude (with sign) of each of those velocity to the animator as parameters.
Can you create a menu system with the new input system? Specifically with drop down menus and sliders using a game pad. There is like nothing out there showing how to do this.
Question - I have terrain that is uneven and when my character runs/walks across it hills, it remain in air and gravity isn't applied. Might the rigidbody mass be too low? Something I need to add in code?
At 16:31 there is an error and on screen text to point it out. For lots of folks this has been the cause of jump issues. If that's not the issue you're more than welcome to jump over to the OWS discord server and we can try and figure out a solution.
How would it be the solving for slope in 2/3D while having same code for movement as in your example ? After checking the normal of the ray how should I move the player and also let him jump ?
I'm not sure exactly what you are trying to do. Might be an easier conversation on Discord? Feel free to come by the OWS discord (link in the description).
Really awesome tutorials, you made! 🙂 Little question: How can i change / blend the animations for crouching / proning? im a bit struggling to get it 😞
@@OneWheelStudio Youre just awesome 🙂Ive found out how to implement other animations, my only problem is: if i change the maxSpeed it causes into slower animationspeed. 😞
Cool vid. I like how well each function is explained. One question though, why not use a Quaternion.Slerp instead of Quaternion.LookRotation in the LookAt() function? LookRotation makes it feel too 2d and snappy when the character rotates. Slerp just adds that smooth feel and you can adjust the rotation speed in the command to a higher value if you want to get a faster rotation etc... The reason I ask, is because I notice a trend in these thirdperson controller tutorials when it comes to this approach. Am I overlooking something by using Slerp instead of LookRotation?
I think the honest answer is that Slerp never made it into my toolbox so to speak. Probably the same for other content creators so we just don't think about it and go with what we've always used.
Personally, I like the immediate change in direction, it feels more arcade-like. I'm interested in games like Chinatown Wars where the 2.5D characters were made with sprites, but I think there's a happy medium that can be struck with full 3D models, you just have to make things move more like a cartoon, fast "poses." If you want realism, use root motion and start with Unity Starter Asset Third Person Controller.
Hey! Thank you for the video, it's been really helpful. How would you go about smoothing out the character rotation in this code? Look rotation is giving me very snappy results.
I haven't played with that myself, but you could add a scaling processer to the binding. It will give you x and y values or 1, make that 0.5 and I'd guess your rotation will be slower and maybe smoother?
Hey, After watching some other videos on movement and rotation on a rigid body character this is probably the best and more to the point. Everything works good for me, the only question I have is ('cause i tried to research but couldn't find anywhere) around 14:20 where you copy paste the GetCameraForward function to the GetCameraRight and you replace the highlighted text from 'forward' to 'right' only in the highlighted text, how is that done? is there shortcut? i've tried Ctrl+F2 and other ways but I can't figure it out. Obviously no rush on this but I think for those like me that don't know would be a great help. Thanks again for this video.
Slopes should be okay if you use a capsule collider. Stairs!?! That's another issue altogether. I couldn't tell you the best way to do that. I might fake it! Have it look like stairs, but keep it smooth.
Stairs are a bit of a mess, I have played with several controllers and most of them seem to offset the collider to be on the top of the mesh having the bottom of the collider where the stair height should be. However, once you offset the collider, the mesh will fall into the ground, you will then need adjust the height of your character based on Raycast distances and then lerp your character's position to keep smooth movement. This works quite well for 90% of applications. Just have to keep in mind when moving the player on Platforms that the movement of the platform might occur after the Raycast of the player thus having the player fall up to the collider for a frame or two.
I ve got somme problems I want to fix, First, the cam go to right when I moove the mouse to the left and left for right, how can I fix that ? Secondly I want to block my camera to only the "front view" like fps with just one view behind him. When I turn, the camera turn too fast so we can't see where we watch
The left/right issue can be fixed by inverting the controls or by adding a negative sign to the horizontal inputs. As for the second issue, sounds like you want a different aim algorithm - I made a video covering the basics of the aim options. czcams.com/video/E1s5HWQyyxg/video.html
How can I initiate Jump action? It doesnt do anything when I press spacebar. Also there seems to be a problem with the gravity script. My player doesn't fall down, it just moves in the same plane.
The issue with the gravity is at 16:31. I made a mistake in the code and put an text based message on the screen pointing it out. I should have made it more obvious. Oops.
Hello, thanks for the video! I got through it but am having issues with gameplay where the camera is very choppy.... I think it is within the animator somewhere since I turned it off and then gameplay looked normal and not choppy/stuttering. any suggestions?
I'm not really sure what that's about. I know a few other folks have commented about it, but never saw it on my end. It does seem weird that the animator would effect the camera. Might be worth playing with the camera target - the base object vs. the animated object?
First of all thanks for such an amazing content, But I am really confused as there are 4 ways to use with new input system like you said in your first video about new input system. As the best ways are only 2 through Messages or by using Unity Events. But in this video your not using Invoke Using Unity Events?
My favorite method is to generate a C# class and using C# action/events. That's the approach that I've used here. It's a work flow I'm comfortable with - but at the end of the day use whatever method works best for you.
This deeply frustrated me too. It seemed inconsistent - i did finally figure it out but now I can’t remember what it was. Do make sure that you have gizmos enabled in the sceneview.
Yes. There was an error in the code with a on screen notification - wasn’t super obvious. Can’t remember exactly where in the video (on mobile) but if you check the comments there should be solutions and time stamps.
You would need to add that functionality. My first thought to do that would be to use the shift button to toggle the max speed. Shouldn't be too hard to add in.
Up and down as in along the y-axis? Rather than use a function like get camera forward you would want a function that returns the upward direction or just use (0,1,0). This would cause the y-input to apply a force along the up/down axis. You'll likely need to turn off gravity or account for it in some way.
@@OneWheelStudio solved it like this: if up down pressed i put vector2.up or down as forcedirection || after this if else i do this if (verticalVelocity.sqrMagnitude > maxSpeed * maxSpeed) rb.velocity = verticalVelocity.normalized * maxSpeed * Time.fixedDeltaTime; /// hope this will help others :) cheers!
Thank you for such an impressive material and explanation! But I had a problem, even two, 1 this character just flies away although the collider and rigidbody are installed and configured exactly like you have, 2 moment is that the animations are not played and the character is in place in the idle pose. What could be the reason? These artifacts?
Having to type to specify the whole joystick and the 2D vector composite not being available from the plus sign are both because you hadn't set the Move action to be a Vector2, rather than a Button. This is a great tutorial, though. I've really been struggling with the coding aspect of movement lately. I'm having two issues with this, though: 1. The Jump Raycast isn't working for me. I might have to mess around with the positioning, but I'm putting that off for now, because... 2. Something about this code has made my player entirely immune to gravity. If I walk off a cliff, they just float, and can walk on air. I am very confused by this one. 🤷♂️ (Both issues are solved! See replies.)
Ok, I don't know why, but if I comment out the line: if (rb.velocity.y < 0) rb.velocity += Vector3.down * Physics.gravity.y * Time.fixedDeltaTime; it stops floating. This shouldn't do anything unless the fallspeed is already negative, though, so I have no idea what's going on.
For issue #2 I made a sign error in the jump code. I added a written comment on screen and fixed it later in the video. You can also check out the linked code which should be correct.
The issue with the raycast is that the origin position is based on the center of the player, rather than the bottom, so it either needed to be longer, or start from a lower position.
Sorry, been busy. Check the comments if you haven't. Lots of folks have had jumping issues, and I'd guess there's a good chance you issue is mentioned.
this has exactly what i need! i just cant get the jump to work. Ive read through the comments to find a solution, and increasing the raycast distance doesnt fix it. ive tested it without the bool and it works fine, with my own animation! could there be something else im missing? I dont think you mentioned anything about tags or layers
It’s possible there are some settings on the animation that aren’t correct. I usually have to just tinker until I find the right setting - it’s not something I do often. But maybe check the root motion. It’s possible the animation is trying to hold the character in place.
There would be a lot of steps to do that! I would suggest researching "triggers" in the animator and "avatar masks." The trigger will let you transition to a new animation - you will need to add a jump animation. Then you can use an avatar mask to have the jump animation only apply to the legs - this allows the arms to still hold a weapon or what ever.
Hello thanks , Nice tutorial. But I am confused. How to walk ? I mean my character is always running........ How to walk ? I mean how to differentiate between run and walk? Sorry if i m asking something silly.................
Thank you for your time. I have a problem. When I press play I can move in all directions and the animations work but when I press jump the character stays in the air.
This happened to someone else who accidently added a "Character Controller" component. Any chance you did that? If not, something in one of the component is likely not set right. Feel free to jump over to the OWS discord - it's easier to help there. Add in some screenshots of the inspector for the player object.
@@OneWheelStudio Thanks for the reply. I only added Rigidbody and CapsuleCollider like you did. Seems like there is no gravity as the chracter wont fall off a ledge either. Maybe I missed a part of the video that addressed this.
Hmm. That’s weird. I would lift the character up so it would fall and start turning components off until you can figure out what is preventing it from falling.
can anyone tell me how to solve this error : Assets\Scripts\ThirdPersonController.cs(9,13): error CS0246: The type or namespace name 'ThirdPersonActionsAsset' could not be found (are you missing a using directive or an assembly reference?) someone please reply fast @OneWheelStudio
Amazing video and helped me understand how the new input system works, but i'm having some issues with my player character constantly going up in the air. I can move around and turn but it seems like he is constantly jumping up into the sky. what could be the issue?
At 16:31 there was an error with on-screen text pointing it out. The error does effect the jump. Could that be the issue?
@@OneWheelStudio well, I saw it and already made the change but that still makes the character float upwards constantly. I even tried copy paste the one from your github, but it still has the issue.
Is it possible you have gravity turned off on the rigidbody?
@@OneWheelStudio nevermind, I found out what the issue was. the issue was that I had the capsule collider as a trigger. which for some reason made it the character go up into the air.
For anyone using Unity version 2021.2.4f1 or higher, in order to select "Add 2D Vector Composite", you need to change the Action Type to "Value" and the Control Type to "Vector 2" in the Action Properties, then you can press the plus sign and it will be called "Add Up/Down/Left/Right Composite".
Thank you
thanks so much i was so confused :)
Thanks man!
Thank you
thanks
Do you like this style of video? Longer, less scripted, and admittedly less concise? Or would shorted scripted videos be more helpful?
i like this style :)
this was a decent vid, but shorter scripted videos are definitely better IMO
This is great! So far the best video I found showing how to implenment the new Input System, Cinemachine, Animation and putting it altogether.
Instead of a series of videos in a long tutorial, I really dig this relatively short form.
p.s. the timestamps are really helpful too, thank you.
This type of videos where you can actually see the bigger picture and the architecture of making games, but at the same time you cover every component and technique that makes up that bigger picture. Big thanks!
Great video! thank's a lot for your work ;)
For anyone not finding creating "input actions", you need to install the input system from your package manager before the first step in this tutorial.
THANK YOU
This video is what I have been looking for for a week. Thanks a lot, great content !
I appreciate you for putting this out. I've been stuck in a lot of weird/bad habits for making controllers, using animator and barely understand the input system and this made it all so much clearer for me, even without following along directly.
Best Player controller tutorial ever! no more spider web animators!
24:37 You can find the animation inside the objects. So click drop down for the object, fbx or whatever it is, and drag the animation from inside of it into the inspector. Great tutorial!
I love this style of videos, keep up the great work! It feels like a one on one tutoring session and that makes walking through the codes and around Unity all that much easier! Thank you for making great videos!
Thank you for your clear explanation of why we normalize the camera look vectors. I finally understand.
There's always, like ALWAYS something new to learn in your videos. Love your content. ❤
I have been watching a lot of Unity tutorial videos trying to get a better understanding of both the new Input System as well as being able to better understand Unity with creating my game and I have to say this has to be the most helpful and beginner friendly tutorial I have seen, and it really allowed me to better understand how to work with creating a character controller. Thank you so much for making this video it has helped me tremendously get better at making my own games!
This was a good start. The code needs some modifications to handle any sort of hill or stairs, but not a bad intro.
Awesome video about third person controller! Thanks!
You are by far the best instructor I've ever seen, thanks for the hours you take to make and upload these videos, you make my life so much better after dealing with learning frustration as a noob in Unity. THANK YOU!
Thank you for making this! I've tried so many character controllers and they all felt wrong. This is perfect for PS2 style or highly stylized games.
Thank you so much! You helped me a lot. I'm new with Unity and C# but after this video I made big steps forward with my project and skills. One step at a time :) More videos like this and I would like to see long video where we could make full game from start to finish.
Hi, thank you for this video, love the video style, keep up with the good work.
I have been trying to wrap my head around this new input system and thanks to you, I think I about have a grasp on it. Thank you for your time and effort. Liked and subbed.
Excellent tutorial! Thanks very much. I don't normally comment on many tutorials but felt I had to in this case. I really like your approach and feel that you've helped me take my understanding of Unity character controlling and physics to the next level. Cheers and keep up the great work. ;-)
The NEW way to set up the 2d Vector is as follows :(
Click on Move
Go to Binding Properties and select "Action Type: Value" then "Control Type: Vector 2"
THEN you can right click Move and Add Up/Down/Left/Right Composite will show up.
It will then add a 3d vector to your drop down for WASD.
So stupid of them to switch that up
Thank you so much
Another great tutorial from O.W.S. Cool!
Thank you! It was a pleasure to look at clean code.
Subscribed.
Excellent tutorial! thank you!
Thanks a lot for the video! Very informative and understandable.
Hey really liked this kind of style of video, very informative, learned a lot. But when you were explaining the movement physics was a bit confusing, maybe do a separate video where you explain this better ?
That’s a fair critique! My day job is a physics teacher so easy to gloss over bits when I’m focused on the code. Was there something in particular about the physics that was unclear? Or all of it? 😛
@@OneWheelStudio This video was was about unity new Input System and boy it delivered. I think it's more a request/suggestion than a critique :D yeah to me physics and math is unity is the bigger hurtle. I do understand them when I get explained, but figure this out by my self or where to start is what melts my brain. Cheers
Totally get that. Always happy to try and answer questions - pop over to the OWS discord any time I can help.
THANK YOU , im a newbie and ive been trying to do this exact motion and movement for 3 days
This video helped me a lot. Thanks!
Nice video, you could probably use some comments on methods you create so that it is more understandable for future use
I found out how to get the jump to work for me!
I created a new private float at the top and named it "RayRange" and set it to 1.25f
After that, I went down to the private bool IsGrounded() function and changed it to the following:
private bool IsGrounded()
{
Vector3 direction = Vector3.down;
Ray ray = new Ray(this.transform.position, transform.TransformDirection(direction * RayRange));
if(Physics.Raycast(ray, out RaycastHit hit, RayRange))
{
return true;
}
else
{
Debug.Log("not grounded");
return false;
}
}
Hope this helps some folks!
Cheers for this, great tutorial
I have some weird issue. The code is the same, and the actions are as well. I checked; the camera is attached, and there are no errors. But my character moves only if I press A and D, and it moves diagonally (kinda). I have no clue why W and S don't work. I will try to fix this, but it seems like I wasted 2 hours on this. In the end, I might just go back to the old version of moving the character because I have no idea at all what the issue might be.
Wait, doesn't the current melee code let player spam attack? Animation will play fine but if we were to put damage mechanic, player would be able to do damage several times during animation just by pressing attack constantly.
Not exactly, but the solution shown also isn't pefect. As shown the player can press the button once and the animation will run and if they press the button again the trigger will get set and when the melee animation finishes it will immediately play again. To resolve this you could check the which animation is playing. You could also dive in to Animation State Behaviors which allow really good control/knowlege of the animation state.
Check Animation: www.reddit.com/r/unity_tutorials/comments/owryhj/3rd_person_controller_new_input_system/
Unity Animatin State Behavior: docs.unity3d.com/ScriptReference/StateMachineBehaviour.html
I have this error.
I have done everything as the video.
No i didnt type the code in ondisable to onenable.
Null reference exception: Object reference not set to an instance of an object ThirdPersonController.FixedUpdate()
NRE: Object ref is normally because something is not being linked together, go through your code, and your hierarchy and make sure you link everything that should be, i.e make sure your camera is linked. Small tip, it's really hard for someone to help you when we can't see your code, 98% of the time it's a typo. Try pasting your code into a reply message and someone might be able to spot the problem.
You are a LIFE SAVER mate :D
my charecter will move but it will only move up or down even A and D make me go ,up and down
and my jump does not work
For the movement: Are you sure BOTH Vector3 GetCameraRight/Forward are set to .y?
right.y = 0;
forward.y = 0;
For anyone who couldn't get the jumping to work , modify your isGrounded function as follows , and create a layer of your choosing and give it to the object you're using as floor , and it should work
private bool IsGrounded()
{
float rayLength = 0.3f;
Ray ray = new Ray(transform.position + Vector3.up * 0.1f, Vector3.down);
int layerMask = LayerMask.GetMask("INSERT LAYER NAME HERE");
if (Physics.Raycast(ray, out RaycastHit hit, rayLength, layerMask))
{
return true;
}
else
{
return false;
}
}
great tutorial , thanks
you cannot drag those animations because they have meshes included those are full animation files with mesh pieces included
if you opened the animation that you said "I can't drag these into the animation slots" and you selected the animation file specifically then dragged it into the blend slot it would work.
I had the same question I was like why can you not drag this into the blend state but that is because that is the entire mesh and not just the animation data
Very good video explained everything nicely
whenever my player goes idle, the next time it moves the animation stays on the first frame. :(
This tutorial is amazing! Can I ask how to add an animation to the jump?
I loke how in 3:22 you're correcting yourself when you said it right xD
Ha! I go a bit cross eyed editing these long videos.
Can you please make a video how this work's in with mobile input. Please.
Thank you for bit on Input System + Cinemachine, but I'm getting jittery movement with the camera now as compared with when I used Mouse X/Y
Idk if youre still having this problem but using interpolate on the rigidbody fixed this issue for me
Interpolate + continuous
I keep getting camera jitter as well as I'm completely frozen in y space. I don't go up or down.
any resolution to this? my gameplay is really jittery and was thinking it has to do with the animator.
Is it just me or does the video at 38:40 start doing a weird skip/stutter for the rest of that segment? (up to ~39:07 )
Hmm. I don’t see it happening. I’d definitely be interested if others see seeing it too.
@@OneWheelStudio it does.
This is very cool. Would you please do a tutorial to show how to combine melee animation with the third person from the starter assets? The code seems to be different. Thanks for this video! :)
Have you found anything on this? Cause I'm struggling too
No, not really. But I think you can combine Mixamo animations and the starter assets. So you could parent a sword to the hand? But I'm not sure about this.
@@juliaalder2007 If you find anything on that then please tell here. And also in this tutorial when I press the W key , the player directly runs from idle when he should just walk. Can you tell how to fix it?
38:40 I thought I was having an aneurysm
One point to square roots calculation in general. This isn't slower anymore most compiler these day can do it in 1 cpu clock cycle. It cant get any faster then this. :)
HEY! Thanks for the Tutorial!
i had an issue with the character, one that made her fly as soon i started the game. It wasnt the code error in 16:32 and it wasn't a capsule collider issue, i find out that this is a problem with the Animator component... to fix this, just disable Apply Root Motion. Hope someone find this useful, thanks for the video
lol
Why do we only multiply the jump descent by Time.fixedDeltaTime isn't everything in FixedUpdate frame rate independent? Also, curious why you choose not to use a CharacterController?
Okay I fixed the missing thirdpersonactionsasset by RENAMING my inupt settings thingy, but I still don't know what to rename RIGIDBODY? I'm using a different unity asset character than yours called Insect4_Green. Do I rename that character to RIGIDBODY? It also has a sub thingy called Body_LP.
plyer isnt facing in direction of input
I'm commenting before following the video, but just by passing my eyes on it, it seens that this is the perfect tutorial for everything i planned to use, so thanks a lot in advance
I hope it lives up to expectations 😉
@@OneWheelStudio Yeah, there are a some tweaks to make (e.g., my move is 2d simple directional, with backwards and sideways specifics animations), but in general a very very solid tutorial, i learned a lot! =DD
How can I make my character run only when i am pressing the shift key? It always transitions into run animation just by pressing the W key...
why do all these tutorials use cinemachine? What if I don't want to add some bloated camera library to my project?
Then get out a pencil and paper and figure out the trig to do it yourself...
what does it mean this ?where can i get ThirdPersonActionsAsset ? Assets\Scripts\ThirdPersonController.cs(10,13): error CS0246: The type or namespace name 'ThirdPersonActionsAsset' could not be found (are you missing a using directive or an assembly reference?)
That means it can't find the class/script in your project. Did you generate the C# class from your input action asset?
If you have other errors that are preventing compilation that could be a problem too - if there aren't any other errors then don't worry about this.
for me there is no mouse delta showing up, I tried pass through and vector2 also value and vector2, any ideas how to solve this?
Amazing video and helped me understand how the new input system works, and can u make tutorial how to make so that when i click control when player moves this player slows down and goes on walk animation
Hey @One Wheel Studio I dont know how to get when the mouse button down for example, could you help me, because I need set an animation for an action that need hold the button down
Great video. You should do the same for touch input for mobile devices.
Great video, very helpful!!
Is there a part 2 related to the zombies?
(can't find it, lol)
No there isn’t but if you check the links in the description you should be able to get the code used for them - it’s pretty basic though.
@@OneWheelStudio thank you so much!!
I have a different question. If I wanted to use a 2d directional animator (for example to make the character able to strafe to the sides with animations) then how would I use that with the new input system?
I'm not sure it's any different with the new input system. Maybe I'm wrong. So here's my first thought on the problem:
You would need to separate out the side to side velocity and the forward/backward velocity - these would need to be relative to the camera's direction. You could look up "vector projections" to project the character velocity onto the camera's direction to get the velocity in the s/s or f/b direction.
From there you could then send the magnitude (with sign) of each of those velocity to the animator as parameters.
Can you create a menu system with the new input system? Specifically with drop down menus and sliders using a game pad. There is like nothing out there showing how to do this.
This is definitely on my list! Can’t promise if or when it’ll get done but it’s definitely on my list.
Question - I have terrain that is uneven and when my character runs/walks across it hills, it remain in air and gravity isn't applied. Might the rigidbody mass be too low? Something I need to add in code?
Oh, and gravity is already enabled on the rigidbody
At 16:31 there is an error and on screen text to point it out. For lots of folks this has been the cause of jump issues. If that's not the issue you're more than welcome to jump over to the OWS discord server and we can try and figure out a solution.
18:57 im big dumb and still have no idea why you square root the magnitude of the vector, anyone know where to find an explanation to this?
How would it be the solving for slope in 2/3D while having same code for movement as in your example ? After checking the normal of the ray how should I move the player and also let him jump ?
I'm not sure exactly what you are trying to do. Might be an easier conversation on Discord? Feel free to come by the OWS discord (link in the description).
Really awesome tutorials, you made! 🙂
Little question: How can i change / blend the animations for crouching / proning? im a bit struggling to get it 😞
Thanks! ☺️ the blending is handled in the transition. Unity will usually do a good job for you but in the transition you can tweak the settings.
@@OneWheelStudio Youre just awesome 🙂Ive found out how to implement other animations, my only problem is: if i change the maxSpeed it causes into slower animationspeed. 😞
Cool vid. I like how well each function is explained. One question though, why not use a Quaternion.Slerp instead of Quaternion.LookRotation in the LookAt() function? LookRotation makes it feel too 2d and snappy when the character rotates. Slerp just adds that smooth feel and you can adjust the rotation speed in the command to a higher value if you want to get a faster rotation etc... The reason I ask, is because I notice a trend in these thirdperson controller tutorials when it comes to this approach. Am I overlooking something by using Slerp instead of LookRotation?
I think the honest answer is that Slerp never made it into my toolbox so to speak. Probably the same for other content creators so we just don't think about it and go with what we've always used.
Personally, I like the immediate change in direction, it feels more arcade-like. I'm interested in games like Chinatown Wars where the 2.5D characters were made with sprites, but I think there's a happy medium that can be struck with full 3D models, you just have to make things move more like a cartoon, fast "poses." If you want realism, use root motion and start with Unity Starter Asset Third Person Controller.
Hey! Thank you for the video, it's been really helpful. How would you go about smoothing out the character rotation in this code? Look rotation is giving me very snappy results.
I haven't played with that myself, but you could add a scaling processer to the binding. It will give you x and y values or 1, make that 0.5 and I'd guess your rotation will be slower and maybe smoother?
Quaternion toRotate = Quaternion.LookRotation(direction, Vector3.up);
this.rb.rotation = Quaternion.RotateTowards(rb.rotation, toRotate, 10f);
Hey,
After watching some other videos on movement and rotation on a rigid body character this is probably the best and more to the point. Everything works good for me, the only question I have is ('cause i tried to research but couldn't find anywhere) around 14:20 where you copy paste the GetCameraForward function to the GetCameraRight and you replace the highlighted text from 'forward' to 'right' only in the highlighted text, how is that done? is there shortcut? i've tried Ctrl+F2 and other ways but I can't figure it out. Obviously no rush on this but I think for those like me that don't know would be a great help. Thanks again for this video.
Glad the video was useful! To rename variables I generally use CTRL + R +R ( press R twice). I believe pressing F2 also works.
Great video! Got one question how would you go up stairs and slopes?
Slopes should be okay if you use a capsule collider. Stairs!?! That's another issue altogether. I couldn't tell you the best way to do that. I might fake it! Have it look like stairs, but keep it smooth.
Stairs are a bit of a mess, I have played with several controllers and most of them seem to offset the collider to be on the top of the mesh having the bottom of the collider where the stair height should be. However, once you offset the collider, the mesh will fall into the ground, you will then need adjust the height of your character based on Raycast distances and then lerp your character's position to keep smooth movement. This works quite well for 90% of applications. Just have to keep in mind when moving the player on Platforms that the movement of the platform might occur after the Raycast of the player thus having the player fall up to the collider for a frame or two.
awesome video but you didn't show the look direction at mouse and controller right stick
Excuse me, I want to know how to connect the gamepad for PC Building Game in Unity?
I ve got somme problems I want to fix, First, the cam go to right when I moove the mouse to the left and left for right, how can I fix that ? Secondly I want to block my camera to only the "front view" like fps with just one view behind him. When I turn, the camera turn too fast so we can't see where we watch
The left/right issue can be fixed by inverting the controls or by adding a negative sign to the horizontal inputs.
As for the second issue, sounds like you want a different aim algorithm - I made a video covering the basics of the aim options. czcams.com/video/E1s5HWQyyxg/video.html
How can I initiate Jump action? It doesnt do anything when I press spacebar. Also there seems to be a problem with the gravity script. My player doesn't fall down, it just moves in the same plane.
The issue with the gravity is at 16:31. I made a mistake in the code and put an text based message on the screen pointing it out. I should have made it more obvious. Oops.
@@OneWheelStudio I'm gonna check it today, thank you for pointing this out
Hello, thanks for the video! I got through it but am having issues with gameplay where the camera is very choppy.... I think it is within the animator somewhere since I turned it off and then gameplay looked normal and not choppy/stuttering. any suggestions?
I'm not really sure what that's about. I know a few other folks have commented about it, but never saw it on my end. It does seem weird that the animator would effect the camera. Might be worth playing with the camera target - the base object vs. the animated object?
@@OneWheelStudio Turning on Interpolate on the Rigidbody fixed the issue for me :)
I like
I am looking to use the new input system to change weapon with the d-pad buttons. But everything I do don't work.
Are the events getting invoked? Are any functions getting called?
First of all thanks for such an amazing content, But I am really confused as there are 4 ways to use with new input system
like you said in your first video about new input system. As the best ways are only 2 through Messages or by using Unity Events. But in this video your not using Invoke Using Unity Events?
My favorite method is to generate a C# class and using C# action/events. That's the approach that I've used here. It's a work flow I'm comfortable with - but at the end of the day use whatever method works best for you.
@@OneWheelStudio thanks
Thanks a lot for that video.
Any idea why I don't see that blue/rect rectangle on game view for the cinematic camera? May be a setting to activate?
This deeply frustrated me too. It seemed inconsistent - i did finally figure it out but now I can’t remember what it was. Do make sure that you have gizmos enabled in the sceneview.
@@OneWheelStudioYes all gizmos with a checkbox are enabled. But a lot of Cinemachine entries don't have a check box.
I reply to myself, you need to have "aim" section expanded on CinemachineFreeLook !!
Quick question, is there a reason my character stays in the air when jumping or going off cliffs?
Yes. There was an error in the code with a on screen notification - wasn’t super obvious. Can’t remember exactly where in the video (on mobile) but if you check the comments there should be solutions and time stamps.
@@OneWheelStudio thanks will check it out!
What is the point of the keyboard movement if you can't walk. If you play keyboard you will only be able to run. Where is the simple shift run?
You would need to add that functionality. My first thought to do that would be to use the shift button to toggle the max speed. Shouldn't be too hard to add in.
I would like to be able to move the char up and down and when having that, not moving on x. How should be the velocity scripted in that case ? ty
Up and down as in along the y-axis? Rather than use a function like get camera forward you would want a function that returns the upward direction or just use (0,1,0). This would cause the y-input to apply a force along the up/down axis. You'll likely need to turn off gravity or account for it in some way.
@@OneWheelStudio solved it like this: if up down pressed i put vector2.up or down as forcedirection || after this if else i do this if (verticalVelocity.sqrMagnitude > maxSpeed * maxSpeed) rb.velocity = verticalVelocity.normalized * maxSpeed * Time.fixedDeltaTime; /// hope this will help others :) cheers!
Thank you for such an impressive material and explanation! But I had a problem, even two, 1 this character just flies away although the collider and rigidbody are installed and configured exactly like you have, 2 moment is that the animations are not played and the character is in place in the idle pose. What could be the reason? These artifacts?
Does this happen when jumping? There was an error in the code that I pointed out via on screen text. This has caused issues for other folks.
As for the animation, sounds like the animation parameter is not getting set correctly? Are there any errors in the console?
Having to type to specify the whole joystick and the 2D vector composite not being available from the plus sign are both because you hadn't set the Move action to be a Vector2, rather than a Button.
This is a great tutorial, though. I've really been struggling with the coding aspect of movement lately.
I'm having two issues with this, though:
1. The Jump Raycast isn't working for me. I might have to mess around with the positioning, but I'm putting that off for now, because...
2. Something about this code has made my player entirely immune to gravity. If I walk off a cliff, they just float, and can walk on air. I am very confused by this one. 🤷♂️
(Both issues are solved! See replies.)
Ok, I don't know why, but if I comment out the line:
if (rb.velocity.y < 0) rb.velocity += Vector3.down * Physics.gravity.y * Time.fixedDeltaTime;
it stops floating. This shouldn't do anything unless the fallspeed is already negative, though, so I have no idea what's going on.
For issue #2 I made a sign error in the jump code. I added a written comment on screen and fixed it later in the video. You can also check out the linked code which should be correct.
As for the first issue, raycasting can be a pain to debug. You can try adding a debug ray call to visualize where the ray it.
@@OneWheelStudio ohhh.... I just missed that, somehow 😅
Thanks for the quick replies!
The issue with the raycast is that the origin position is based on the center of the player, rather than the bottom, so it either needed to be longer, or start from a lower position.
would this be the same for a character controller? would i just replace rigidbody with character controller?
I honestly have explored the character controller much, but what’s shown in the video should be adaptable to the character controller component.
@@OneWheelStudio I'll give it a shot
How can I make my player jump, please reply!!
Sorry, been busy. Check the comments if you haven't. Lots of folks have had jumping issues, and I'd guess there's a good chance you issue is mentioned.
Great tutorial, im habing some issues but is because me i dont understand at all your code!
Thank you for video! Can you make video about Touch input for mobile divice?
I have almost zero experience with mobile, but I do get a lot of requests. So maybe some day. Can't promise it'll happen soon.
In the third person controller from the starter assets mobile is implemented.
this has exactly what i need! i just cant get the jump to work. Ive read through the comments to find a solution, and increasing the raycast distance doesnt fix it. ive tested it without the bool and it works fine, with my own animation! could there be something else im missing? I dont think you mentioned anything about tags or layers
It’s possible there are some settings on the animation that aren’t correct. I usually have to just tinker until I find the right setting - it’s not something I do often. But maybe check the root motion. It’s possible the animation is trying to hold the character in place.
No composite options when I right click the action. Send halp.
In the action properties set "action type" to "value" and the control type to "vector 2"
Can you please make a third person tutorial for bolt 🙂
THANK UUU
How would you add a jump animation to this setup?
There would be a lot of steps to do that! I would suggest researching "triggers" in the animator and "avatar masks." The trigger will let you transition to a new animation - you will need to add a jump animation. Then you can use an avatar mask to have the jump animation only apply to the legs - this allows the arms to still hold a weapon or what ever.
Hello thanks , Nice tutorial.
But I am confused. How to walk ? I mean my character is always running........ How to walk ? I mean how to differentiate between run and walk? Sorry if i m asking something silly.................
Thank you for your time. I have a problem. When I press play I can move in all directions and the animations work but when I press jump the character stays in the air.
This happened to someone else who accidently added a "Character Controller" component. Any chance you did that?
If not, something in one of the component is likely not set right. Feel free to jump over to the OWS discord - it's easier to help there. Add in some screenshots of the inspector for the player object.
@@OneWheelStudio Thanks for the reply. I only added Rigidbody and CapsuleCollider like you did. Seems like there is no gravity as the chracter wont fall off a ledge either. Maybe I missed a part of the video that addressed this.
Gravity should be turned on by default on the rigidbody. Check that.
@@OneWheelStudio Yes "Use Gravity" on the Rigidbody is checked.
Hmm. That’s weird. I would lift the character up so it would fall and start turning components off until you can figure out what is preventing it from falling.
Hello sir, Can we make videos on 3rd person shooter with different type of gun using Animation rigging ?
can anyone tell me how to solve this error :
Assets\Scripts\ThirdPersonController.cs(9,13): error CS0246: The type or namespace name 'ThirdPersonActionsAsset' could not be found (are you missing a using directive or an assembly reference?) someone please reply fast @OneWheelStudio
@OneWheelStudio
@OneWheelStudio
Sounds like the input asset didn’t generate the C# file.
@@OneWheelStudio no it did
@@OneWheelStudio do you have discord or insta i can send a pic