Tap to unmute

Move in Unity3D - Ultimate Unity Tutorial

  • Жарияланды 2023 ж. 24 Нау.

Пікірлер • 425

  • Romulino
    Romulino 2 жыл бұрын +198

    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.

    • EddieJr Digital Arts
      EddieJr Digital Arts  Жыл бұрын

      @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?

    • Rikrish Shrestha
      Rikrish Shrestha 2 жыл бұрын +1

      That is what's called 'Experience' like on the field. not just solo dev.

    • Ruben DW
      Ruben DW 2 жыл бұрын +1


    • LanPodder
      LanPodder 2 жыл бұрын +1

      Agree with that. Tons of tutorials out there are hard to extend on.

  • Jason Storey
    Jason Storey 2 жыл бұрын +49

    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

  • A B
    A B 2 жыл бұрын +78

    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

    • Zyrnnh
      Zyrnnh  Жыл бұрын +3

      Do one, keep your focus on it, finish it. Good luck!

    • Avinash Jain
      Avinash Jain 2 жыл бұрын +3

      Jason Weimann your reply has the same likes as the original comment .
      By the way love your videos

    • Jason Weimann
      Jason Weimann  2 жыл бұрын +73

      Make one today!

  • Evan
    Evan 2 жыл бұрын +1

    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

  • Brent Grigsby
    Brent Grigsby  Жыл бұрын

    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.

  • Ricki Moore
    Ricki Moore 2 жыл бұрын

    This is indeed the ultimate tutorial...easy to understand examples, decent pace and visual examples. 10/10

  • Peyman Mortazavi
    Peyman Mortazavi  Жыл бұрын

    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.

  • Kyle Davies
    Kyle Davies 2 жыл бұрын +1

    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!

  • 2135 - Fahad Alvi
    2135 - Fahad Alvi 2 жыл бұрын +4

    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 :)

  • MongooseInferno
    MongooseInferno 2 жыл бұрын

    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.

  • Bdub
    Bdub  Жыл бұрын

    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.

  • Gaurav Garg
    Gaurav Garg 2 жыл бұрын

    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?

  • Paul LeBlanc
    Paul LeBlanc 11 ай бұрын

    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.

  • thp1972
    thp1972 2 жыл бұрын

    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.

  • Mikael Wendt
    Mikael Wendt 2 жыл бұрын +3

    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.

  • Culver Polley
    Culver Polley  Жыл бұрын

    Fantastic tutorial, beyond teaching me different ways to create movement you've also inspired me to combine techniques in creative ways!

  • Ben Patient
    Ben Patient  Жыл бұрын

    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.

  • Tistou Blomberg
    Tistou Blomberg 2 жыл бұрын +2

    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!

  • Ricardo F. Alves
    Ricardo F. Alves 2 жыл бұрын +1

    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!

  • PanikGrafik
    PanikGrafik  Жыл бұрын

    Amazing! Ive been looking for someone not to just say the code but to actually explain the thoughtprocess and workings of the code!

  • Omar Moataz
    Omar Moataz 2 жыл бұрын +1

    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

  • Tracey P
    Tracey P 2 жыл бұрын +3

    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!!

  • Eric Le
    Eric Le 2 жыл бұрын

    Absolutely fantastic and super helpful video! Thank you for sharing this, Jason!

  • PapaSage
    PapaSage  Жыл бұрын

    I like the way you ease into such daunting subjects. Thank you for the video!

  • projects
    projects 2 жыл бұрын +2

    This is the most amazing tutorial EVER! Thank you so much for your time and energy... :)

  • Rik Roy
    Rik Roy  Жыл бұрын

    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!

  • Frank F
    Frank F  Жыл бұрын

    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.

  • Alan Morgan, Planet Postmoderna
    Alan Morgan, Planet Postmoderna  Жыл бұрын

    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.

  • MISC
    MISC 5 ай бұрын

    nice tutorial... simple, step by step, precise, this is what i'm looking for

  • Eluem
    Eluem  Жыл бұрын

    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.

  • Shakybones
    Shakybones 2 жыл бұрын

    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!

  • Jacob Hallberg
    Jacob Hallberg 2 жыл бұрын +2

    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

  • Pukemoth
    Pukemoth 2 жыл бұрын +3

    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?

  • Kyle Gerbrandt
    Kyle Gerbrandt 2 жыл бұрын

    Great video, just what I needed. I was starting to write down all the different ways of moving an object and was getting overwhelmed.

  • Zemer Muzik
    Zemer Muzik 2 жыл бұрын

    Thank you very much for this awesome tutorial!!
    Also, thank you for sharing your vast knowledge with an aspiring self-taught game developer.

  • Mike Schmitz
    Mike Schmitz 2 жыл бұрын

    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?

  • Miroslav Sali
    Miroslav Sali 2 жыл бұрын +6

    It's really cool that you are making tutorials for the new Unity version.

  • ZoidbergForPresident
    ZoidbergForPresident 2 жыл бұрын

    Very cool video! It's not always easy keeping in mind how all those ways work and which ones to use at specific times.

    • ZoidbergForPresident
      ZoidbergForPresident 2 жыл бұрын

      So basically either move the transform or use force? Eventually using a character controller?

  • Flint Montana
    Flint Montana 2 жыл бұрын +2

    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.

  • Gredran
    Gredran 2 жыл бұрын

    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!

  • Eng. Abdullah Hassan ⚡
    Eng. Abdullah Hassan ⚡ 2 жыл бұрын +1

    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

    EXP LLC 2 жыл бұрын +5

    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.

  • The Steve
    The Steve 2 жыл бұрын

    Amazing tutorial. I just started with unity and this made so much sense.

  • Alec Anderson
    Alec Anderson 2 жыл бұрын

    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

  • shariz A8
    shariz A8 2 жыл бұрын

    it was very useful you make great unity tutorials keep up the great work

  • Matthew Rye
    Matthew Rye 2 жыл бұрын

    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?

  • teh1archon
    teh1archon 2 жыл бұрын

    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.

  • Kev_The_Creator
    Kev_The_Creator 2 жыл бұрын

    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.

  • Steven Graziano
    Steven Graziano 2 жыл бұрын

    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!

  • Malcolm Dixon
    Malcolm Dixon 17 күн бұрын

    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.

  • Melty Sensei
    Melty Sensei 2 жыл бұрын +3

    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!

    VAIVS 2 жыл бұрын

    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.

  • Paul Player
    Paul Player  Жыл бұрын

    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.

  • dejo095
    dejo095 2 жыл бұрын

    Learning so much from your videos, thank you 👍

  • Stephen Tyson
    Stephen Tyson 2 жыл бұрын +3

    Honestly the best Unity tutorial on KZclip.

  • Jason Williams
    Jason Williams  Жыл бұрын

    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 :)

  • Midoringo Ch. みどりんご
    Midoringo Ch. みどりんご 2 жыл бұрын +1

    thank you so much, as a beginner I found this guide exteremely helpful. your explanation is very transparent

  • Crixino
    Crixino 2 жыл бұрын +1

    Great video! I love your tutorials!

  • Paweł Lewandowski
    Paweł Lewandowski 2 жыл бұрын

    Really like yours channel. This video is very cool, really help me understand how to move Objects in Unity. Thanks for great content :)

  • HydraOrc's Games
    HydraOrc's Games 2 жыл бұрын

    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

  • Tobi Klejbach
    Tobi Klejbach 2 жыл бұрын

    Half way through and must say this video is amazingly helpful

  • Kimmo Laine
    Kimmo Laine 2 жыл бұрын +1

    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.

  • Christoph Krass
    Christoph Krass 2 жыл бұрын

    This is just great work :) thank you so much :D

  • 256kMagic
    256kMagic 2 жыл бұрын

    Great video, would like to see something similar except with flight based movement of a simple plane or space ship.

  • woodn't metal
    woodn't metal 2 жыл бұрын

    this is a great and neat tutorial! thank you!

  • GusTaVp
    GusTaVp 2 жыл бұрын +4

    This video is exactly what im looking for since i start to learn c#. Thanks a lot!

  • Potatopossum
    Potatopossum 2 жыл бұрын

    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!

    • Kitchen Spider
      Kitchen Spider 2 жыл бұрын

      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.

  • C
    C 2 жыл бұрын

    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?

  • Anand Satheesan
    Anand Satheesan 2 жыл бұрын

    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.

  • MrCZRC
    MrCZRC 2 жыл бұрын

    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

  • Ian Graham
    Ian Graham 2 жыл бұрын

    What a way to end a Sunday evening! Thanks for sharing Jason, some excellent tips!

  • Maxawe Some
    Maxawe Some 2 жыл бұрын

    Awesome video, man ! Just one question, why use Fixed Update instead of Update when using Character Controller ?

  • Hennadii_S
    Hennadii_S 8 ай бұрын

    Thank You, this is amazing learning material, very helpful.

  • Abassi Anis
    Abassi Anis 2 жыл бұрын

    Amazing content as always ! Thank you so much ^__^

  • 43 yrs ago
    43 yrs ago 2 жыл бұрын

    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!

  • digitalconsciousness
    digitalconsciousness  Жыл бұрын

    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.

  • Citizen
    Citizen 2 жыл бұрын

    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 :/

  • Sid Bell
    Sid Bell 2 жыл бұрын +1

    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...

    • Jason Weimann
      Jason Weimann  2 жыл бұрын +1

      Very different, but also still far from being used by most unity devs. Ill do a new one whenever I make the switch tho :)

  • No. 2 Hailsteel Fan
    No. 2 Hailsteel Fan 2 жыл бұрын

    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!

    • Saeed Prez
      Saeed Prez 2 жыл бұрын

      I don't think it supports 2D, I've seen some people use this: github.com/h8man/NavMeshPlus

  • Raiden Heaven
    Raiden Heaven 2 жыл бұрын +7

    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;
    private float speed, groundAngle, deadzone, speedPerSecond, dragPerSecond, topSpeed , touchingForce;
    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()
    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;

    • C
      C 2 жыл бұрын

      @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.
      if(normal.y < 0.7f)
      steep_slope = true;
      // change speed based on slope
      if(player_velocity.y >= 0)
      move_speed *= normal.y;
      move_speed *= 1 + (1 - normal.y);

    • Raiden Heaven
      Raiden Heaven 2 жыл бұрын +1

      @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?

    • Raiden Heaven
      Raiden Heaven 2 жыл бұрын

      @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?

    • Raiden Heaven
      Raiden Heaven 2 жыл бұрын

      @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

    • C
      C 2 жыл бұрын

      @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.

    FULL SPEED FLY 2 жыл бұрын

    Another great tutorial! Thanks Jason!

  • Dreamz
    Dreamz  Жыл бұрын

    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?

  • __.Lucky.__
    __.Lucky.__ 2 жыл бұрын +2

    Perfect timing. Just watched tons of tutorials about this topic 👌👍

  • hasa ali
    hasa ali 2 жыл бұрын

    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?

  • DaveStomper
    DaveStomper  Жыл бұрын

    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

  • Aimen Sadouki
    Aimen Sadouki 2 жыл бұрын

    u make learning things so easy and fun, ty!

  • Ali Rathore
    Ali Rathore  Жыл бұрын

    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.

  • Levent Bozkurt
    Levent Bozkurt 2 жыл бұрын

    Great lesson. Thank you.

  • Łukasz Jabcoń
    Łukasz Jabcoń 2 жыл бұрын

    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?
    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

  • gtg238s
    gtg238s 2 жыл бұрын

    Great tutorial very easy to follow! Ps I didn’t know Duncan Trussell could code!

  • Haim Katav
    Haim Katav 2 жыл бұрын +1

    As always, great video!
    Thanks a lot buddy ur the best!

  • Carmine Applesauce
    Carmine Applesauce 2 жыл бұрын

    Thank you, this is has been extremely helpful!

  • Laviz Pandey
    Laviz Pandey 2 жыл бұрын

    This is not a qwestion. Just a message of appretiation from a big fan. Thank you for all you have done for the community.

  • אריק
    אריק 2 жыл бұрын

    I am sure gonna follow this one right after two others of yours 😅. Thanks a lot 😁

  • HPloveCraftMacNcheese
    HPloveCraftMacNcheese  Жыл бұрын

    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.

  • Juggling Joe Studios
    Juggling Joe Studios 2 жыл бұрын

    Fantastic - thank you very much!

  • foreign- living the american dream

    great video, didn't notice it were 50 min long 👍

  • Siren Gita
    Siren Gita  Жыл бұрын

    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