your videos are in a completely different level than 90% of the unity content in youtube. Everything else seems very amateur and based on trial and error but you can explain things in a way that makes sense and gives me building blocks to actually progress on my understanding of unity and what can I do with it. Thank you sir.
@Rikrish Shrestha Are you implying that solo dev isn't considered experience in the field? Do people need to work on big companies to be validated their experience?
another fun snapping one like the shift you you learned is hold the "V" key, lets you snap the selected object to verts, great for placing distance object onto a terrain surface nearby or lining up a wall segments bottom left corner etc
Nice explanations and nice progression from the simple stuff to NavMeshAgents. I have been using Unity for almost a year now (hobby), and you taught me a few things, so thank you. It appears that the CharacterController component is similar to the NavMeshAgent component, but you have to supply the motion/pathing yourself.
I love the content you create. I'm a new Unity folk and your videos are immensely helpful. I've used tutorials on plural sight and even Unity courses and none have given me the high level picture you paint. Very helpful and I appreciate it a lot.
I don't usually comment on videos, but man your video was by far the most helpful out of everything I've watched. Explaining why and what things do are much more important than just showing lines of code and telling us to follow along! Thanks!
I did it make it to the end. Thank you so much for this! As a complete beginner this has been SO helpful. Just a very minor gripe in the character controller section ( 27:35 ) I was expecting a brief pros and cons between RigidBody and Character Controller and why would someone choose one over the other. But not complaining at all. Again, thank you so much for such an indepth tutorial :)
Use the Animator's Update Mode! It was set to Normal, but if you set it to Physics it will play much nicer with movement. Using physics as the update mode mean that it occurs with FixedUpdate, as you might expect. It's useful for any animation that might interact with hitboxes, even if they aren't solid. Some people suggest using the animator to position and trigger hitboxes, but this would normally cause your gameplay to become framerate dependent. By using physics to animate, your hitboxes would then become consistent. It's a neat approach, but we have to be careful to not overload the physics step as well.
Amazing tutorials. I understood the objects I was playing with in unity much better and was able to get them to do what I wanted within 20 minutes on this channel.
Hey Jason, I liked your videos. The way you are explaining the concept is really outstanding. I am wondering if you are planning to launch a series on ARCore or AR tools?
You have a really great teaching style Jason, I've learned so much from your channel. I come here first when I need things clarified in an intelligent and succinct manner. You are my next Patreon subscription.
Hello. Just a little suggestion to improve the video: you could add that to move objects you can also use transform.Translate. This is a good method because it takes into account the conversion between world coordinates and local coordinates when there are rotations.
Very neat and informative video, differently a format you should embrace further on. Despite knowing most of it by itself, it was nice to see the different methods and approaches compared to one another. I would love to see videos in this format on Access Modifiers, Operators, Namespaces and other fundamentals. Your code look very different from mine, using a lot of serialize fields and lambda expressions. I would love you to explain your coding philosophies on that level.
I thought I was going to watch a boring tutorial with basic stuff. But NOPE, many great tips and information here. It's clear you put a lot of effort into this content and for that, thank you, Jason!
Great tutorial on the basics! I have coding experience, but am just getting started with Unity to make a VR simulation. Your videos are just the right level for me. I will be consuming your channel. Thanks for this!!
Maybe you should also explain rigidbody.movePosition or transform move with raycasts/ spherecasts. Could be useful for someone. Also, please let me know if these are bad approaches in general. Love your content btw!
In the Jump script we need to prevent the user from hitting the Space key repeatedly until the cube is grounded again, otherwise it is possible to send it into the stratosphere.
Very good tutorial... also the only one I've seen that uses forces to make a rigidbody character controller. Most seem to just use rigidbody.MovePosition or directly controlling velocity.
Hi, Jason! Fantastic video, as usual. How do you deal with the problem of Rigidbody bouncing down slopes? I've tried checking for slope with a Raycast and then applying transform.position -= transform.up * (slopeForce * Time.deltaTime), with slopeForce set empirically in the editor. This works somewhat, but it difficult to tune and still has issues. Thanks for any advice you can offer!
This is the best tutorial I have ever watched! You are the first one to get me to understand the difference between Rigidbody and Character Controller! Up until now I thought it was just Rigidbody: Physics Character Controller: No physics
For the character controller portion, my movement was messed up until I removed the Rigidbody. Does the Character Controller innately behave the same way a Rigidbody does? I'm assuming it was messed up because the two components were competing against each other, much like if you have two planes occupying the same surface in 3d modeling - the engine doesn't know which one to go with?
Love your content Jason! please keep making these tutorials they are so much better than the majority of the others out there. I just finished the jump section and I'm getting a flappy bird type jump mechanic, would I need to add a GetKeyUp the GetKeyDown to make it a jump once thing or do I need a isGrounded type bool to accomplish that?
Hi Jason, great video ranging from super basic to super useful! I had a question on .isGrounded for character controllers, Do you find it consistently reliable if used in FixedUpdate? My .isGrounded (albiet in Update) was blinking on and off a lot especially when i was standing still. I ended up just using a short raycast instead, but i am curious. Thanks.
I've seen you promoted on Brackeys, but have seen your style that is on another level and another perspective, because of how long you've been in the business! I'm definitely gonna consider getting one of your courses!
Can you please increase the transparency of the circle around the cursor? Sometimes it covers small details. Also you can make the pointer larger in black without this circle (suggestion) :) I really appreciate your efforts. Thank you
Hello Jason, I've been having extraordinary trouble using the new Input System since it's quite different from the old system. I'm trying to learn it from the beginning of my game dev path so that I don't have to relearn such a critical part later on. Is there any reason you aren't using it in your recent videos? Also, any chance you could make a new video regarding the new Input System (the one you have out is a bit outdated, 9+ months). Thanks and love your videos.
Great video! I had no idea you could set up booleans the way you did in those movement scripts. I've just been assigning their values in the update method lol
Thanks Jason, this looks to be a valuable reference resource. I think three 15 minute videos would have fit into my viewing schedule better. Is there any way to tell if a NavMeshAgent is able to reach a destination? Is there a navigation component for flying AI? Something built-in for path finding off the mesh?
I knew and even used the vertex snap but after 1.5 years of doing only 2D in uGUI (we don't use "sprites" only UI components) I totally forgot about it. Great video. I'm not at the end yet but from the timestamps, I guess lerping is not in the video. Maybe you can show how to move transforms over time with iTween/DOTween (I'd go to the later) and with coroutines.
Thank you so much! I'm trying to learn more about programming for a game my friend and I planned on making and this helped me understand how C# interacts with the objects in unity.
I recently started getting serious with Unity and have been cramming on it for the last half year though as I'm much older, it's taking me a little while longer to 'get it'. I am scouring the net for decent tutorials and you've quickly become one of my favorite authoritative voices on it. If and when I can scrounge up the money to take your course, I'll definitely sign up!
Thanks Jason, some different code (and simpler) than I've seen on other tutorials but one question that must be asked because this is different than others is WHY use FixedUpdate for moving the CharacterController, others just use Update. Now, I recall you said that CharacterController under the hood is basically a RigidBody, which I know you use FixedUpdate as it uses Physics (providing it's not Kinematic)., so can you please clarify that I'm understanding this correctly? Thanks for your time.
Since i started progamming 13 years ago i am always been making some small 2D games (using Delphi, Pygame(Python), Monogame(C#)) for fun (I work as a software consultant). But i have never been confident enough to get into 3D games. Thanks to you i am finally beginning this journy. Thanks for your videos and sharing your invaluable knowledge with us.
Great video full of useful info , thanks. I have a question though, using simple objects, how can I rotate a cube to reflect the slope angle of the ground it is on? This is fine for a capsule as it stays vertical regardless of ground slope, but a cube should rotate to sit more realistically on sloping ground. I'd appreciate any pointers.
Hello, Jason. I have a movement question. I use a star pathfinding + navmesh agent + collider + kinematic rigidbidy for unit movements in my rts game. But units push each other when moving, instead of avoiding collision when possible. How can I achieve a desired behaviour either with a star or nav mesh agent? P.S. Rvo local avoidance does not work for my case
Very nice. Noob question: when should I use physic based translation and when..directly manipulating position? If I understood this correctly, the physic based is a simulation and thus more expensive.
Thank you for the video. The knowledge you share has helped me greatly. I do have a question regarding the new input system. Do you think it is worth using in a simple single player game? Or are the older input methods the way to go? Just seems like the new system is a bit cumbersome when the same thing can be achieved with a few lines of code. (Plus I don't see the old methods going away, maybe just used less) Thanks again Jason!
I'd like to know too. Most of what I find on here is using the old input system and I can't seem to figure out why there aren't any really good explanations of the new system beyond very basic movement that doesn't take into account rotation, gravity, camera, jumping, animations, smoothing, etc. I can implement a very simplified movement script with a character controller using the new input system, but translating info from tutorials that feature the old system gets really hairy when you start wanting to do anything that involves quaternions and forward direction calculations. I'd really like to see a barebones 3rd person movement implementation with the new input system that uses mouselook for direction/orientation and doesn't leave my character floating all over the y axis. I'd also like to know why none of the yt regulars (ie. brackeys, weimann, etc) don't appear to be releasing anything about it and why videos are still popping up with the old system. The new system isn't that new IIRC. Is there a reason no one is touching it? Is there something better about the old system beyond knowing you can find a lot of resources online about it? Whats with the neglect here? Searching for info on the new system has become a royal pita, because you never know what you're gonna get... you have to click through each video, dissect their code to see if they are using it, and throw it back into the water like a fish you can't eat. I know I'm probably spoiled and a bit jaded from tutorial hell, but man it gets annoying trying to find what you need sometimes.
Hi Jason, I'm currently converting Quakes player movement system into Unity but I encountered a huge issue when it comes to collision detection. Unity's collision detection system returns collision points instead of planes and as a result the collision normal surface is arbitrary. If you place a sphere collider on the corner of a step and draw a line in the direction of the collision normal it changes depending on the angle of collision. This is causing major problems as the character will occasionally jitter or catch the corners of tiny objects. Using planar collisions instead will return a consistent surface normal that does not change based on the angle of collision. Unfortunately there doesn't appear to be any built in components to retrieve plane collisions. So as a result I am having to resort to using bsp trees to split up the mesh into triangles (planes), calculating which triangle is closer, and then checking if any of those planes intersect with the player's bounding box. This is an awful lot of work for something that I feel should be accounted for, particularly in modern game engines. Is there any reason why Unity uses point collision instead of plane collisions?
I always face problems with detecting incoming collisions and triggering collision events while using CharacterController setup. Collisions are happening only if the character moves and collides with another collider but not reverse. What I mean is that the character is not colliding with any other collider that is intended to pass through it. I dont know if there's any way around this but because of this reason I always end up using the Rigidbody setup.
For people who havent used character controller also know it comes with an annoying glitch if you have same set up moving capsule at 2 meters but make step offset for example 0.5 or 1 and try to move under / through object like a door way where there is clearly a 0.5 to 1 gap it will get stuck or move slow through it as if it cannot fit. This all depends on step offset even though step offset is only supposed to be for going up steps. This glitch has been around for years and may frustrate those for hours who have never come across it
I tried and failed at a hand-crafted movement system where I was updating the translate through update(). It was flawless until I got to collisions. Player was going through the terrain at high speeds. The problem was too big to fix with the system I had, so switching to CharacterController seemed the easiest. Beautiful code at 34:30 right there. Worked like a charm and got me headed in the right direction. The moral of the story is if you plan on having collisions, best to choose a movement system that is intertwined with Unity's physics so it can do fixedupdates correctly.
Neat stuff Jason but wonder about your approach to deeper Navmesh stuff which is local avoidance which is not working well if you try to use it in RTS development. For example controlling 50 units with mouse click while i figure out how to set their behaviour to not bash into eachother fighting for destination i'm curious how you can deal with something like: Got 50 units selected (tanks), hit RMB on enemy to attack and in the moment units approach firing range and should stop to shoot first few do this perfectly but then their block the way for others to approach shooting range, they should bypass already shooting units and continue route to target till they reach shooting range then stop and start shooting. Problem is local avoidance of agents its work only for half a unity unit, dont calculate path to bypass other agents and end up bashing into already stopped ones :/
Beginner question: Is it possible to set up a NavMesh for a 2D Tilemap? Ever since finding out about NavMeshAgents I've tried to find some tutorial or explanation on how to incorporate them in 2D games, but to no avail. Any tips on how to approach such a problem are greatly appreciated! Also, really love your videos Jason, they're the most informative and professional when it comes to Unity and Game Programming!
@Raiden Heaven Quake uses algorithms to calculate physics, and the units are almost the same as Unity, only multiplied by ten. I think using normals is much easier than angles IMO. Example: if(normal.y < 0.7f) steep_slope = true; // change speed based on slope if(player_velocity.y >= 0) move_speed *= normal.y; else move_speed *= 1 + (1 - normal.y);
@C doesn't quake uses a physics engine like Unreal? To make not "jumping on down slopes" I use Quaternions because I want to turn the whole vector. Can you turn something without Quaternions?
@R1PFake Because the I want to check for collisions. The OnCollisionStay() runs on each update and the inputs are counted somewhere in the Update. So, I'm using the LateUpdate to be sure that I read my input after it has been updated. Also, the LateUpdate it's ok to run for small things. 1 frame it's a super fine delay. You play fighting games with more :p
@Luiz Vaz it isn't really necessary to convert normals into angle vectors, but it depends on what you use them for. You can just use the Y normal axis to determine slope steepness. Plus dealing with floats is much more preferable than dealing with Quaternions and converting angles to radians or Eulers.
One issue I'm having is with the controller jump. My "is grounded" variable keeps randomly ticking on and off even when I'm standing still on the ground. This makes it very hard to rely on the jump key consistently working. I've tried adjusting my collision and mesh position and all sorts of stuff but no luck, nothing changes this. Anyone have some advice?
Greetings. Your explanation is good. I have a question. I want to do more than one scene. What is the method or there is a video that indicates appreciation?
Hi thanks for the movemnt tutorials. I am seeing a bug though when I try it when we added the rotations on the q and e keys it started placing the cube in the middle of the ground and sink it half way in the ground plane
hi mate, excellent tutorial, wanted to ask how to you handle making the player face the way its moving with rotation in character controller . move function. Also when you leave movement the char still face the way u were going.
I love the video and it helped me a lot, but I have an issue with the character controller script. If Input.GetKey(KeyCode) is set to Space my character does not jump. Same when I change the code to Input.GetKeyDown(Keycode.Space) it does not work. Every other key can be specified and works just fine, but not the space key. Any idea why this is happening? EDIT Never mind ;) apparently it's a known bug. Happens in Linux, don't know if any other OS is affected. No fix, but it only happens in editor, so if you build and test the game you will be able to use the script without having to use a different key to jump. Hope it helps anyone with the same issue as mine
I'm making a tower defense game, and I want to use navmesh to control the enemy AI. The problem is I can't get turrets to rotate toward a game object if it has a NavMeshAgent controller attached.
I can code all the other parts of a game now sans save files (just pure mental fear on that one lol) but for some reason i can never remember how to get a good basic movement setup going xD Love these detailed classes, ty SO MUCHHHHH
your videos are in a completely different level than 90% of the unity content in youtube. Everything else seems very amateur and based on trial and error but you can explain things in a way that makes sense and gives me building blocks to actually progress on my understanding of unity and what can I do with it.
Thank you sir.
@Rikrish Shrestha Are you implying that solo dev isn't considered experience in the field?
Do people need to work on big companies to be validated their experience?
That is what's called 'Experience' like on the field. not just solo dev.
Exactly.
Agree with that. Tons of tutorials out there are hard to extend on.
another fun snapping one like the shift you you learned is hold the "V" key, lets you snap the selected object to verts, great for placing distance object onto a terrain surface nearby or lining up a wall segments bottom left corner etc
I'm starting to learn how to code in general, I found your channel and couldn't be happier. I hope to make a game someday
Do one, keep your focus on it, finish it. Good luck!
Jason Weimann your reply has the same likes as the original comment .
By the way love your videos
Make one today!
This is one of the best Unity tutorials I've seen so far! Please consider doing more videos like this, it's incredibly valuable for new users
Nice explanations and nice progression from the simple stuff to NavMeshAgents. I have been using Unity for almost a year now (hobby), and you taught me a few things, so thank you. It appears that the CharacterController component is similar to the NavMeshAgent component, but you have to supply the motion/pathing yourself.
This is indeed the ultimate tutorial...easy to understand examples, decent pace and visual examples. 10/10
I love the content you create. I'm a new Unity folk and your videos are immensely helpful. I've used tutorials on plural sight and even Unity courses and none have given me the high level picture you paint. Very helpful and I appreciate it a lot.
I don't usually comment on videos, but man your video was by far the most helpful out of everything I've watched. Explaining why and what things do are much more important than just showing lines of code and telling us to follow along! Thanks!
I did it make it to the end. Thank you so much for this! As a complete beginner this has been SO helpful. Just a very minor gripe in the character controller section ( 27:35 ) I was expecting a brief pros and cons between RigidBody and Character Controller and why would someone choose one over the other. But not complaining at all. Again, thank you so much for such an indepth tutorial :)
Use the Animator's Update Mode! It was set to Normal, but if you set it to Physics it will play much nicer with movement.
Using physics as the update mode mean that it occurs with FixedUpdate, as you might expect. It's useful for any animation that might interact with hitboxes, even if they aren't solid. Some people suggest using the animator to position and trigger hitboxes, but this would normally cause your gameplay to become framerate dependent. By using physics to animate, your hitboxes would then become consistent.
It's a neat approach, but we have to be careful to not overload the physics step as well.
Amazing tutorials. I understood the objects I was playing with in unity much better and was able to get them to do what I wanted within 20 minutes on this channel.
Hey Jason, I liked your videos. The way you are explaining the concept is really outstanding. I am wondering if you are planning to launch a series on ARCore or AR tools?
You have a really great teaching style Jason, I've learned so much from your channel. I come here first when I need things clarified in an intelligent and succinct manner. You are my next Patreon subscription.
Hello. Just a little suggestion to improve the video: you could add that to move objects you can also use transform.Translate. This is a good method because it takes into account the conversion between world coordinates and local coordinates when there are rotations.
Very neat and informative video, differently a format you should embrace further on. Despite knowing most of it by itself, it was nice to see the different methods and approaches compared to one another.
I would love to see videos in this format on Access Modifiers, Operators, Namespaces and other fundamentals. Your code look very different from mine, using a lot of serialize fields and lambda expressions. I would love you to explain your coding philosophies on that level.
Fantastic tutorial, beyond teaching me different ways to create movement you've also inspired me to combine techniques in creative ways!
Great video. Would be helpful to have some guidance on how to choose between different approaches as it is a lot of work to unpick them later on.
Really efficient and thorough, great speed! Didn't even notice it was 50 min, thought it was 15 or something. Good recap of the moving options!
I thought I was going to watch a boring tutorial with basic stuff. But NOPE, many great tips and information here.
It's clear you put a lot of effort into this content and for that, thank you, Jason!
Amazing! Ive been looking for someone not to just say the code but to actually explain the thoughtprocess and workings of the code!
I actually managed to make a 2d game from your channel, and now that brakeys is gone, I think you may be the number one unity guider for beginners
Great tutorial on the basics! I have coding experience, but am just getting started with Unity to make a VR simulation. Your videos are just the right level for me. I will be consuming your channel. Thanks for this!!
Absolutely fantastic and super helpful video! Thank you for sharing this, Jason!
I like the way you ease into such daunting subjects. Thank you for the video!
This is the most amazing tutorial EVER! Thank you so much for your time and energy... :)
Maybe you should also explain rigidbody.movePosition or transform move with raycasts/ spherecasts. Could be useful for someone. Also, please let me know if these are bad approaches in general.
Love your content btw!
In the Jump script we need to prevent the user from hitting the Space key repeatedly until the cube is grounded again, otherwise it is possible to send it into the stratosphere.
Thank you Jason! I so needed this tutorial. I have been learning C# in Unity. This tutorial shed a lot of light in areas that were just not clear.
nice tutorial... simple, step by step, precise, this is what i'm looking for
Very good tutorial... also the only one I've seen that uses forces to make a rigidbody character controller. Most seem to just use rigidbody.MovePosition or directly controlling velocity.
Hi, Jason! Fantastic video, as usual.
How do you deal with the problem of Rigidbody bouncing down slopes? I've tried checking for slope with a Raycast and then applying transform.position -= transform.up * (slopeForce * Time.deltaTime), with slopeForce set empirically in the editor. This works somewhat, but it difficult to tune and still has issues. Thanks for any advice you can offer!
This is the best tutorial I have ever watched! You are the first one to get me to understand the difference between Rigidbody and Character Controller! Up until now I thought it was just
Rigidbody: Physics
Character Controller: No physics
For the character controller portion, my movement was messed up until I removed the Rigidbody. Does the Character Controller innately behave the same way a Rigidbody does? I'm assuming it was messed up because the two components were competing against each other, much like if you have two planes occupying the same surface in 3d modeling - the engine doesn't know which one to go with?
Great video, just what I needed. I was starting to write down all the different ways of moving an object and was getting overwhelmed.
Thank you very much for this awesome tutorial!!
Also, thank you for sharing your vast knowledge with an aspiring self-taught game developer.
Love your content Jason! please keep making these tutorials they are so much better than the majority of the others out there.
I just finished the jump section and I'm getting a flappy bird type jump mechanic, would I need to add a GetKeyUp the GetKeyDown to make it a jump once thing or do I need a isGrounded type bool to accomplish that?
It's really cool that you are making tutorials for the new Unity version.
Very cool video! It's not always easy keeping in mind how all those ways work and which ones to use at specific times.
So basically either move the transform or use force? Eventually using a character controller?
Hi Jason, great video ranging from super basic to super useful! I had a question on .isGrounded for character controllers, Do you find it consistently reliable if used in FixedUpdate? My .isGrounded (albiet in Update) was blinking on and off a lot especially when i was standing still. I ended up just using a short raycast instead, but i am curious. Thanks.
I've seen you promoted on Brackeys, but have seen your style that is on another level and another perspective, because of how long you've been in the business! I'm definitely gonna consider getting one of your courses!
Can you please increase the transparency of the circle around the cursor? Sometimes it covers small details.
Also you can make the pointer larger in black without this circle (suggestion) :)
I really appreciate your efforts. Thank you
Hello Jason, I've been having extraordinary trouble using the new Input System since it's quite different from the old system. I'm trying to learn it from the beginning of my game dev path so that I don't have to relearn such a critical part later on. Is there any reason you aren't using it in your recent videos? Also, any chance you could make a new video regarding the new Input System (the one you have out is a bit outdated, 9+ months). Thanks and love your videos.
Amazing tutorial. I just started with unity and this made so much sense.
Great video! I had no idea you could set up booleans the way you did in those movement scripts. I've just been assigning their values in the update method lol
it was very useful you make great unity tutorials keep up the great work
Thanks Jason, this looks to be a valuable reference resource. I think three 15 minute videos would have fit into my viewing schedule better.
Is there any way to tell if a NavMeshAgent is able to reach a destination?
Is there a navigation component for flying AI? Something built-in for path finding off the mesh?
I knew and even used the vertex snap but after 1.5 years of doing only 2D in uGUI (we don't use "sprites" only UI components) I totally forgot about it.
Great video. I'm not at the end yet but from the timestamps, I guess lerping is not in the video. Maybe you can show how to move transforms over time with iTween/DOTween (I'd go to the later) and with coroutines.
Thank you so much! I'm trying to learn more about programming for a game my friend and I planned on making and this helped me understand how C# interacts with the objects in unity.
I recently started getting serious with Unity and have been cramming on it for the last half year though as I'm much older, it's taking me a little while longer to 'get it'. I am scouring the net for decent tutorials and you've quickly become one of my favorite authoritative voices on it. If and when I can scrounge up the money to take your course, I'll definitely sign up!
Thanks Jason, some different code (and simpler) than I've seen on other tutorials but one question that must be asked because this is different than others is WHY use FixedUpdate for moving the CharacterController, others just use Update. Now, I recall you said that CharacterController under the hood is basically a RigidBody, which I know you use FixedUpdate as it uses Physics (providing it's not Kinematic)., so can you please clarify that I'm understanding this correctly? Thanks for your time.
Side note: Brackey's did a great job presenting your Udemy ad on their videos. That's how I found your KZclip channel. Great content please continue!
Since i started progamming 13 years ago i am always been making some small 2D games (using Delphi, Pygame(Python), Monogame(C#)) for fun (I work as a software consultant). But i have never been confident enough to get into 3D games. Thanks to you i am finally beginning this journy. Thanks for your videos and sharing your invaluable knowledge with us.
Great video full of useful info , thanks. I have a question though, using simple objects, how can I rotate a cube to reflect the slope angle of the ground it is on? This is fine for a capsule as it stays vertical regardless of ground slope, but a cube should rotate to sit more realistically on sloping ground. I'd appreciate any pointers.
Learning so much from your videos, thank you 👍
Honestly the best Unity tutorial on KZclip.
I went with character controller because it seems to go through walls less but now I need to get that to work on a moving platform :)
thank you so much, as a beginner I found this guide exteremely helpful. your explanation is very transparent
Great video! I love your tutorials!
Thanks!
Really like yours channel. This video is very cool, really help me understand how to move Objects in Unity. Thanks for great content :)
Hello, Jason. I have a movement question. I use a star pathfinding + navmesh agent + collider + kinematic rigidbidy for unit movements in my rts game. But units push each other when moving, instead of avoiding collision when possible. How can I achieve a desired behaviour either with a star or nav mesh agent? P.S. Rvo local avoidance does not work for my case
Half way through and must say this video is amazingly helpful
Very nice. Noob question: when should I use physic based translation and when..directly manipulating position? If I understood this correctly, the physic based is a simulation and thus more expensive.
This is just great work :) thank you so much :D
Great video, would like to see something similar except with flight based movement of a simple plane or space ship.
this is a great and neat tutorial! thank you!
This video is exactly what im looking for since i start to learn c#. Thanks a lot!
Thank you for the video. The knowledge you share has helped me greatly. I do have a question regarding the new input system. Do you think it is worth using in a simple single player game? Or are the older input methods the way to go?
Just seems like the new system is a bit cumbersome when the same thing can be achieved with a few lines of code. (Plus I don't see the old methods going away, maybe just used less) Thanks again Jason!
I'd like to know too. Most of what I find on here is using the old input system and I can't seem to figure out why there aren't any really good explanations of the new system beyond very basic movement that doesn't take into account rotation, gravity, camera, jumping, animations, smoothing, etc. I can implement a very simplified movement script with a character controller using the new input system, but translating info from tutorials that feature the old system gets really hairy when you start wanting to do anything that involves quaternions and forward direction calculations. I'd really like to see a barebones 3rd person movement implementation with the new input system that uses mouselook for direction/orientation and doesn't leave my character floating all over the y axis. I'd also like to know why none of the yt regulars (ie. brackeys, weimann, etc) don't appear to be releasing anything about it and why videos are still popping up with the old system. The new system isn't that new IIRC. Is there a reason no one is touching it? Is there something better about the old system beyond knowing you can find a lot of resources online about it? Whats with the neglect here? Searching for info on the new system has become a royal pita, because you never know what you're gonna get... you have to click through each video, dissect their code to see if they are using it, and throw it back into the water like a fish you can't eat. I know I'm probably spoiled and a bit jaded from tutorial hell, but man it gets annoying trying to find what you need sometimes.
Hi Jason,
I'm currently converting Quakes player movement system into Unity but I encountered a huge issue when it comes to collision detection. Unity's collision detection system returns collision points instead of planes and as a result the collision normal surface is arbitrary. If you place a sphere collider on the corner of a step and draw a line in the direction of the collision normal it changes depending on the angle of collision. This is causing major problems as the character will occasionally jitter or catch the corners of tiny objects. Using planar collisions instead will return a consistent surface normal that does not change based on the angle of collision.
Unfortunately there doesn't appear to be any built in components to retrieve plane collisions. So as a result I am having to resort to using bsp trees to split up the mesh into triangles (planes), calculating which triangle is closer, and then checking if any of those planes intersect with the player's bounding box. This is an awful lot of work for something that I feel should be accounted for, particularly in modern game engines. Is there any reason why Unity uses point collision instead of plane collisions?
I always face problems with detecting incoming collisions and triggering collision events while using CharacterController setup. Collisions are happening only if the character moves and collides with another collider but not reverse. What I mean is that the character is not colliding with any other collider that is intended to pass through it. I dont know if there's any way around this but because of this reason I always end up using the Rigidbody setup.
For people who havent used character controller also know it comes with an annoying glitch if you have same set up moving capsule at 2 meters but make step offset for example 0.5 or 1 and try to move under / through object like a door way where there is clearly a 0.5 to 1 gap it will get stuck or move slow through it as if it cannot fit. This all depends on step offset even though step offset is only supposed to be for going up steps. This glitch has been around for years and may frustrate those for hours who have never come across it
What a way to end a Sunday evening! Thanks for sharing Jason, some excellent tips!
Awesome video, man ! Just one question, why use Fixed Update instead of Update when using Character Controller ?
Thank You, this is amazing learning material, very helpful.
Amazing content as always ! Thank you so much ^__^
Glad you enjoyed it! Thanks!
I'm having a problem with what type of movement should I use to start making my 1st game. This video will really help me for sure, thanks!
I tried and failed at a hand-crafted movement system where I was updating the translate through update(). It was flawless until I got to collisions. Player was going through the terrain at high speeds. The problem was too big to fix with the system I had, so switching to CharacterController seemed the easiest. Beautiful code at 34:30 right there. Worked like a charm and got me headed in the right direction. The moral of the story is if you plan on having collisions, best to choose a movement system that is intertwined with Unity's physics so it can do fixedupdates correctly.
Neat stuff Jason but wonder about your approach to deeper Navmesh stuff which is local avoidance which is not working well if you try to use it in RTS development.
For example controlling 50 units with mouse click while i figure out how to set their behaviour to not bash into eachother fighting for destination i'm curious how you can deal with something like:
Got 50 units selected (tanks), hit RMB on enemy to attack and in the moment units approach firing range and should stop to shoot first few do this perfectly but then their block the way for others to approach shooting range, they should bypass already shooting units and continue route to target till they reach shooting range then stop and start shooting. Problem is local avoidance of agents its work only for half a unity unit, dont calculate path to bypass other agents and end up bashing into already stopped ones :/
Hi Jason, a useful video as always!
Just a quick (maybe stupid) question - Is it any different if we're using ECS? I've heard it's the future...
Very different, but also still far from being used by most unity devs. Ill do a new one whenever I make the switch tho :)
Beginner question: Is it possible to set up a NavMesh for a 2D Tilemap? Ever since finding out about NavMeshAgents I've tried to find some tutorial or explanation on how to incorporate them in 2D games, but to no avail. Any tips on how to approach such a problem are greatly appreciated! Also, really love your videos Jason, they're the most informative and professional when it comes to Unity and Game Programming!
I don't think it supports 2D, I've seen some people use this: github.com/h8man/NavMeshPlus
Always use LateUpdate() for your inputs, never on FixedUpdate(). OnCollisionStay() is called on every frame that's why use LateUpdate to get your inputs.
Use a material with no friction. The following code does that and it does stands on a slopes (no friction needed) but has one problem, "Slope Jump"
It's work in progress... but it does work with same in 3d and 2d. (with the same problems)
private Rigidbody2D rb;
private Collider col;
private Vector2 inputDirection, vector2zero, direction, accelerationVelocity, deaccelerationVelocity, targetForce, downVector, velocityDot, contactSam;
private float acceleration;
private float deacceleration;
[SerializeField]
private float speed, groundAngle, deadzone, speedPerSecond, dragPerSecond, topSpeed , touchingForce;
[SerializeField]
private bool touching;
// Start is called before the first frame update
void Start()
{
rb = GetComponent();
col = GetComponent();
vector2zero = Vector2.zero;
}
// Update is called once per frame
void LateUpdate()
{
inputDirection = vector2zero;
inputDirection.y += Input.GetKey(KeyCode.W) ? 1 : 0;
inputDirection.x -= Input.GetKey(KeyCode.A) ? 1 : 0;
inputDirection.y -= Input.GetKey(KeyCode.S) ? 1 : 0;
inputDirection.x += Input.GetKey(KeyCode.D) ? 1 : 0;
speed = rb.velocity.magnitude;
}
void FixedUpdate()
{
InitialVolumes();
SimpleForce();
}
private void InitialVolumes()
{
direction = inputDirection.normalized;
direction = Quaternion.Euler(0, 0, groundAngle) * direction;
acceleration = speedPerSecond * Time.fixedDeltaTime;
deacceleration = dragPerSecond * Time.fixedDeltaTime;
}
private void SimpleForce()
{
accelerationVelocity = direction.normalized * acceleration;
if (Vector2.Dot(accelerationVelocity + rb.velocity, direction.normalized) > topSpeed)
accelerationVelocity -= direction.normalized * (Vector2.Dot(accelerationVelocity + rb.velocity, direction.normalized) - topSpeed);
deaccelerationVelocity = direction.normalized * Vector2.Dot(rb.velocity, direction.normalized) - rb.velocity;
deaccelerationVelocity = Quaternion.Euler(0, 0, -groundAngle) * deaccelerationVelocity;
deaccelerationVelocity.y = 0;
if (deaccelerationVelocity.magnitude > deacceleration)
deaccelerationVelocity = deaccelerationVelocity.normalized * deacceleration;
deaccelerationVelocity = Quaternion.Euler(0, 0, groundAngle) * deaccelerationVelocity;
downVector = Quaternion.Euler(0, 0, groundAngle) * Physics2D.gravity;
targetForce = accelerationVelocity + deaccelerationVelocity;
targetForce += downVector * Time.fixedDeltaTime;
if (touching)
{
targetForce += downVector * touchingForce;
}
rb.AddForce(targetForce, ForceMode2D.Impulse);
}
void OnCollisionEnter2D(Collision2D collision)
{
contactSam = vector2zero;
foreach (ContactPoint2D contact in collision.contacts)
{
contactSam += contact.normal;
}
contactSam = contactSam.normalized;
touching = true;
groundAngle = (Mathf.Atan2(contactSam.y, contactSam.x) * Mathf.Rad2Deg) - 90;
}
void OnCollisionStay2D(Collision2D collision)
{
contactSam = vector2zero;
foreach (ContactPoint2D contact in collision.contacts)
{
contactSam += contact.normal;
}
contactSam = contactSam.normalized;
touching = true;
groundAngle = (Mathf.Atan2(contactSam.y, contactSam.x) * Mathf.Rad2Deg) - 90;
}
void OnCollisionExit2D(Collision2D collision)
{
groundAngle = 0f;
touching = false;
}
@Raiden Heaven Quake uses algorithms to calculate physics, and the units are almost the same as Unity, only multiplied by ten.
I think using normals is much easier than angles IMO.
Example:
if(normal.y < 0.7f)
steep_slope = true;
// change speed based on slope
if(player_velocity.y >= 0)
move_speed *= normal.y;
else
move_speed *= 1 + (1 - normal.y);
@Luiz Vaz Hi, can you please tell me the logic with the two Raycast? Why one vertical and one horizontal? How you get the angle?
@C doesn't quake uses a physics engine like Unreal? To make not "jumping on down slopes" I use Quaternions because I want to turn the whole vector. Can you turn something without Quaternions?
@R1PFake Because the I want to check for collisions. The OnCollisionStay() runs on each update and the inputs are counted somewhere in the Update. So, I'm using the LateUpdate to be sure that I read my input after it has been updated. Also, the LateUpdate it's ok to run for small things. 1 frame it's a super fine delay. You play fighting games with more :p
@Luiz Vaz it isn't really necessary to convert normals into angle vectors, but it depends on what you use them for. You can just use the Y normal axis to determine slope steepness. Plus dealing with floats is much more preferable than dealing with Quaternions and converting angles to radians or Eulers.
Another great tutorial! Thanks Jason!
One issue I'm having is with the controller jump. My "is grounded" variable keeps randomly ticking on and off even when I'm standing still on the ground. This makes it very hard to rely on the jump key consistently working. I've tried adjusting my collision and mesh position and all sorts of stuff but no luck, nothing changes this. Anyone have some advice?
Perfect timing. Just watched tons of tutorials about this topic 👌👍
Greetings. Your explanation is good. I have a question. I want to do more than one scene. What is the method or there is a video that indicates appreciation?
Hi thanks for the movemnt tutorials. I am seeing a bug though when I try it when we added the rotations on the q and e keys it started placing the cube in the middle of the ground and sink it half way in the ground plane
u make learning things so easy and fun, ty!
hi mate, excellent tutorial, wanted to ask how to you handle making the player face the way its moving with rotation in character controller . move function. Also when you leave movement the char still face the way u were going.
Great lesson. Thank you.
I love the video and it helped me a lot, but I have an issue with the character controller script. If Input.GetKey(KeyCode) is set to Space my character does not jump. Same when I change the code to Input.GetKeyDown(Keycode.Space) it does not work. Every other key can be specified and works just fine, but not the space key. Any idea why this is happening?
EDIT
Never mind ;) apparently it's a known bug. Happens in Linux, don't know if any other OS is affected. No fix, but it only happens in editor, so if you build and test the game you will be able to use the script without having to use a different key to jump. Hope it helps anyone with the same issue as mine
Great tutorial very easy to follow! Ps I didn’t know Duncan Trussell could code!
As always, great video!
Thanks a lot buddy ur the best!
Thank you, this is has been extremely helpful!
This is not a qwestion. Just a message of appretiation from a big fan. Thank you for all you have done for the community.
I am sure gonna follow this one right after two others of yours 😅. Thanks a lot 😁
I'm making a tower defense game, and I want to use navmesh to control the enemy AI. The problem is I can't get turrets to rotate toward a game object if it has a NavMeshAgent controller attached.
Fantastic - thank you very much!
great video, didn't notice it were 50 min long 👍
I can code all the other parts of a game now sans save files (just pure mental fear on that one lol) but for some reason i can never remember how to get a good basic movement setup going xD Love these detailed classes, ty SO MUCHHHHH