Control Mixamo Characters with the Unity Input System

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 106

  • @galan2541
    @galan2541 4 месяца назад +1

    Dude, thank you so much! Finally found the video w/o any useless explanation and just straight to the point! Subscribed 👏👏

  • @taimoori
    @taimoori 2 года назад +6

    Amazing work and movement system setup. I was searching for this for months.
    Thanks ❤️

  • @jroc6745
    @jroc6745 3 года назад +1

    This helped me understand the input system better thank you. A request for a future video or series, a Sprint like GTA where you button mash. Nobody seems to have a video on button mash to sprint. They all use "hold shift down".

    • @sodarocketstudios
      @sodarocketstudios  3 года назад

      My first thought for that is to create a speed multiplier variable with a default value of 1. Then everytime you press the button, you increase it by a small amount until it reaches the max value.
      To get the deceleration part, you could either subtract a small amount from the multiplier each frame (This would be a very linear deceleration). Or, maybe do something like
      Multiplier *= .9
      I can think about it a bit more, but that would be my first approach.

    • @jroc6745
      @jroc6745 3 года назад

      @@sodarocketstudios Thanks for the quick reply. Forgive me Im new so I understand what you're suggesting but not the code. Hopefully when you get time you can make a video on it. It would be something nobody else has covered. Thanks again tho. Peace

  • @phoenixcreations94
    @phoenixcreations94 5 месяцев назад +1

    The best tutorial ever, but one missimg thing sir, how can i make it from walking to running ? 😊

    • @sodarocketstudios
      @sodarocketstudios  5 месяцев назад +1

      Thanks! I don't have a video on it, but what you are looking for are called blend trees. Then, you just need to multiply the speed by a sprint multiplier in the movement code.

  • @petethechin
    @petethechin Год назад +1

    Very Very helpful, TYVM

  • @johnpotesta3744
    @johnpotesta3744 2 года назад +1

    Thank you

  • @manfredjohannes2771
    @manfredjohannes2771 Год назад +1

    love it

  • @cosimodemedici1530
    @cosimodemedici1530 17 дней назад

    I've follwed and inputed the code for Jump but when I press play my player automatically shoots up into the air like a rocket.

  • @juliaalder2007
    @juliaalder2007 3 года назад +1

    Thank you so much!!! :)

    • @sodarocketstudios
      @sodarocketstudios  3 года назад

      No problem, I hope I covered everything you wanted to see.

    • @juliaalder2007
      @juliaalder2007 3 года назад

      @@sodarocketstudios I'm working right now. Tomorrow I can watch the whole video. 🤗

    • @juliaalder2007
      @juliaalder2007 3 года назад

      @@sodarocketstudios I really love it. It`s to the point and I understand everything you do. Thanks again!

  • @CharithaCn
    @CharithaCn 3 месяца назад

    project file is missing the most important file the player controller 😢

  • @martinrodriguez2803
    @martinrodriguez2803 Год назад +2

    im having issues with the player controller script (not having the Move Speed*) and when i try to add the OnMove* to the Player Input/Events/Control, it doesnt pop up for me? could i have done the script wrong? im a first time use to unity so everything is new to me. Thank you in advance for the help

    • @sodarocketstudios
      @sodarocketstudios  Год назад

      For the Move speed, do you have [SerializeField] before the vector declaration? I.e. [SerializeField] private float MoveSpeed; and for the onMove function you need to make sure you use the Public keyword so: public void OnMove. The other problem would be if the function doesn't accept a callback context. In that case you want it to look like this, OnMove(InputAction.CallbackContext context).
      I assumed you meant that these things weren't showing up in the inspector, which is the window in the unity editor that shows you all of the components on a selected game object. If that is the case, then it is most likely you are missing something I described above. Otherwise, I may have misunderstood your problem. If this doesn't fix your problems I can try to help you walk through it more.

    • @martinrodriguez2803
      @martinrodriguez2803 Год назад +1

      ​@@sodarocketstudios yeah, I made sure the script matches what you provided, I wonder if it's because I'm using an updated version of unity? and yes if you are free to walk me through it would greatly appreciate it!

    • @sodarocketstudios
      @sodarocketstudios  Год назад +1

      Let's start with the Move speed then, since it will probably be easier to solve. If you can give me some more detail on the problem, it will help me figure what is going on.

    • @martinrodriguez2803
      @martinrodriguez2803 Год назад

      @@sodarocketstudios (using this code)
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.InputSystem;
      public class PlayerController : MonoBehaviour
      {
      [SerializeField]
      private float moveSpeed = 1;
      private Vector2 moveVector;
      private CharacterController characterController;
      // Start is called before the first frame update
      void Start()
      {
      characterController = GetComponent();
      }
      // Update is called once per frame
      void Update()
      {
      Move();
      }
      public void OnMove(InputAction.CallbackContext context)
      {
      moveVector = context.Readvalue();
      }
      private void Move()
      {
      Vector3 move = transform.right*moveVector.x + transform.forward*moveVector.y;
      characterController.Move(move*moveSpeed*Time.deltaTime);
      }
      }

    • @sodarocketstudios
      @sodarocketstudios  Год назад

      That was a tricky one to catch. The error was only useful for pointing out where it was, but I believe the issue is that you didn't capitalize the v in ReadValue in your OnMove function.

  • @princekogaianmikoshi405
    @princekogaianmikoshi405 2 года назад +2

    In the input control's where you made the jump function If I add in another a 3rd button F for Fly what button on a controller would you make it I was thinking L3 or so R3 can be dash or run

    • @sodarocketstudios
      @sodarocketstudios  2 года назад +2

      You can use any button you want. Personally, I like the idea of reusing the jump button and in the OnJump method add, if (isGrounded) then jump else fly.

  • @VisualV.
    @VisualV. 3 года назад +2

    Hi! First of a all, Great Video! The problem I'm facing is that OnJump function is not showing in player input events however the OnMove and OnLook are working perfectly fine! Any Idea What could be the reason for the same?
    Your Explanation is Top Notch and you earned yourself a subscriber!

    • @sodarocketstudios
      @sodarocketstudios  3 года назад

      If you could paste the header of your on jump function, it might be a bit easier. The most basic errors I can think of that would cause that are having OnJump set to private, or if you have a parameter other than a callback context.

    • @VisualV.
      @VisualV. 3 года назад

      @@sodarocketstudios Sure Let me get back to you👍

  • @traynorth83
    @traynorth83 8 месяцев назад +1

    how do i get the orientation box on character to its feet?

    • @sodarocketstudios
      @sodarocketstudios  8 месяцев назад

      If you are talking about the collider, you should be able to move it around in the inspector until it matches up correctly.

    • @traynorth83
      @traynorth83 8 месяцев назад

      @@sodarocketstudios No i mean the green ,red, and blue orientation box. mine is in the middle of my player.

    • @sodarocketstudios
      @sodarocketstudios  8 месяцев назад

      The most common method is to create an empty parent object that contains the object with the player model as a child. Then, you can adjust the location of the child object with the model on it until the feet are on the ground.

    • @traynorth83
      @traynorth83 8 месяцев назад

      @@sodarocketstudios thank you so much

  • @vinnaweng
    @vinnaweng Год назад +1

    Great tutorial, but jump seems not working. When I clicked on play, the character just kept flying and disappeared.

    • @sodarocketstudios
      @sodarocketstudios  Год назад

      I'm guessing you got a sign wrong somewhere, make sure the gravity is applying a negative y to the velocity.
      I changed my mind on where I put the negative sign in the video, so I wouldn't be surprised if you set gravity as negative and then in the on move you have another negative sign canceling it out.

    • @vinnaweng
      @vinnaweng Год назад

      @@sodarocketstudios Thanks. I fixed the gravity sign. Your code works great! I added a mesh collider to the 3D scene, then the character won't keep falling out of the scene. :D

  • @dadsspaghetti9774
    @dadsspaghetti9774 2 года назад +1

    Hey man i know this is a dumb question but for some reason i cant find the onmove in the player input

    • @sodarocketstudios
      @sodarocketstudios  2 года назад +1

      It's a function that you have to create before you can connect it to the input system. If you did make it, then make sure it is public. If you don't specify it is set to private by default and you won't be able to see it.

  • @1xMuchx1
    @1xMuchx1 3 года назад +1

    Great content and very nice explanation

    • @sodarocketstudios
      @sodarocketstudios  3 года назад +1

      If you pass in a reference to the cinemachine virtual camera, you can adjust the z component of the follow offset to move the camera up and down. it might be easier to setup the camera like I do in this video ruclips.net/video/dqfVlSxOXv8/видео.html.

    • @sodarocketstudios
      @sodarocketstudios  2 года назад +1

      I created a unity package of the project and put a link to it in the description. You will need to make sure you install cinemachine and the input system package to get it to work right.

  • @danishsaeed7969
    @danishsaeed7969 Год назад +1

    Jump is not working after I pressed Space button it didn't work??

    • @sodarocketstudios
      @sodarocketstudios  Год назад

      The easiest way to fix it is to walk through each part and check it. I would start by making sure your input action is set up correctly. Then make sure you have connected the jump method to the jump action on the player input manager. If both of those are correct, then it is likely something wrong with the jump function. If it is a problem with code, I will need to know more to help.

    • @danishsaeed7969
      @danishsaeed7969 Год назад +1

      @@sodarocketstudios Thanks of the reply, but I have corrected it on the moment 😊

  • @kurtlosbanos6123
    @kurtlosbanos6123 3 года назад +1

    Hi. I followed your tutorial until 8:31 but when I press the play button, it isn't my character that is moving but the camera itself. How to fix this? My camera is the one that is moving not the character.

    • @sodarocketstudios
      @sodarocketstudios  3 года назад

      Did you attach the avatar controller script to the player instead of the camera?

    • @kurtlosbanos6123
      @kurtlosbanos6123 3 года назад

      @@sodarocketstudios yes on the player. I attached it on the player. I just followed your instructions

    • @sodarocketstudios
      @sodarocketstudios  3 года назад

      @@kurtlosbanos6123 I'm not sure how that happens since I use a character controller to move the character. Unless your character is a child object of the camera, but then both would be moving. are your character and camera two completely separate game objects?

    • @kurtlosbanos6123
      @kurtlosbanos6123 2 года назад

      @@sodarocketstudios Yes they are separate. I would like to send you a picture but I don't know how and I cant comment pictures in youtube.

  • @elonmusk4823
    @elonmusk4823 2 года назад +1

    can i have that script it is hard to type pls

    • @sodarocketstudios
      @sodarocketstudios  2 года назад

      I will put it up when I get a chance. Unfortunately I won't have access to the computer with the files for awhile.

  • @atulyadav1159
    @atulyadav1159 3 года назад +1

    @Soda Rocket Studios can you add video for third-person shooting controlling guns and animations.

    • @sodarocketstudios
      @sodarocketstudios  3 года назад +1

      I can definitely start looking into it. I might do something a bit less specific to try and keep it useful for more people.
      This is just a guess, but I suspect that for something like guns, instead of making character animations for each specific gun, you could put target points on the gun and use inverse kinematics (I'm not an expert at animation, so this could be very wrong.). I played with that a tiny bit when I was making the Mixamo video. I can start researching, and, if it looks like an approach that makes sense, I can make a video explaining how to do it. If I covered third-person shooter controls, I might make it it's own video. Were you thinking things like how to aim and setup a crosshair, then how to determine what the player is shooting?

    • @atulyadav1159
      @atulyadav1159 3 года назад +1

      @@sodarocketstudios thank you so much. Yes i was thinking about aim and shooting.

    • @sodarocketstudios
      @sodarocketstudios  3 года назад

      I might try to do a video on the controls portion first. I think I would be able to get it out faster. I definetly recommend doing some research on it in the meantime if you need it soon.

    • @atulyadav1159
      @atulyadav1159 3 года назад

      Sure i will do some research.

  • @AryanRekhi
    @AryanRekhi Год назад +1

    Can you please continue this tutorial to add a shift sprint and make this bit smooth

    • @sodarocketstudios
      @sodarocketstudios  Год назад

      To add sprinting, you just need to change the movement speed when the sprint key is pressed.

    • @AryanRekhi
      @AryanRekhi Год назад

      @@sodarocketstudios what if statement where do a GetKeyDown press shift = increase the speed of the player and play the sprinting animation
      Will that work?

    • @sodarocketstudios
      @sodarocketstudios  Год назад

      With how I setup the control script, I think the easiest way would be to add in a sprint input action. Then in the player controller script add an OnSprint function just like all of the other controls. In that function you will want to check the phase of the sprint button. If the phase is started(meaning the button was pressed) you can multiply the movement speed by some sprint speed multiplier. If the phase is canceled (meaning the button was released) you can then divide my that speed multiplier.
      So you will have:
      If(context.started)
      MovementSpeed*=sprintMultiplier
      If(context.canceled)
      MovementSpeed/=sprintMultiplier

    • @AryanRekhi
      @AryanRekhi Год назад

      @@sodarocketstudios is it possible that I can share my updated script with you on Twitter or something so that you can look into it , and if you can also tell me what could I change in animator window with sprint animation

    • @sodarocketstudios
      @sodarocketstudios  Год назад

      On Twitter I am @SodaRocketDev. Or if you go to my channel, you can get my email (I don't want to put it in a comment to avoid bots). As for the animation part, I haven't done too much with animations so I can't tell you exactly what to do, but I can point you toward blend trees. I know there are several tutorials on them, and I think that might be what you are looking for.

  • @vinesseyt
    @vinesseyt 3 года назад +1

    Extra code for rotation? Using A and D from wasd

    • @sodarocketstudios
      @sodarocketstudios  3 года назад +1

      instead of the mouse delta.x being added to the rotation vector, add the x component of the move input vector multiplied by some rotation speed value. I believe that will work. I am in a game jam right now, but If you need more help, I can try some things after this week.

    • @vinesseyt
      @vinesseyt 3 года назад

      @@sodarocketstudios Yeah I am pretty stuck so I would love getting more help once you are free if that is possible

    • @sodarocketstudios
      @sodarocketstudios  3 года назад

      @@vinesseyt The quick and dirty way you can accomplish this is to comment out ReadValue in the OnLook method, then in On move, change
      moveVector = context.ReadValue();
      to
      moveVector.y = context.ReadValue().y;
      and right after that, add
      lookVector.x = context.ReadValue().x;
      Instead of telling the character to walk left or right, you are now telling the camera to rotate based on the A and D input. It will be very slow, so you may need to increase the sensitivity multiplier when setting the rotation.

  • @GinesLA
    @GinesLA 2 года назад +1

    jump dont works for me

    • @sodarocketstudios
      @sodarocketstudios  2 года назад

      In what way does it not work? I can try to walk through it with you.

  • @danishsaeed7969
    @danishsaeed7969 Год назад

    Hi, I didn't find that Input Actions?? Can anyone help me??

    • @ellavonck704
      @ellavonck704 7 месяцев назад

      i know its a bit late but you need to install the input system package, package manager -> unity registry -> input system

  • @BenGodot
    @BenGodot 2 года назад +1

    how would you do this for first person?

    • @sodarocketstudios
      @sodarocketstudios  2 года назад +1

      The easiest way would be to create an empty game object under the character hierarchy. You will put this object where you want the eyes to be. then set the camera (Not a cinemachine virtual camera) as a child of the eyes object and set the position as (0,0,0).

    • @BenGodot
      @BenGodot 2 года назад

      @@sodarocketstudios thank you!

    • @BenGodot
      @BenGodot 2 года назад +1

      @@sodarocketstudios this works great, but the player starts to randomly move around unless you move forward and I'm not sure how to make it so you can look left and right

    • @sodarocketstudios
      @sodarocketstudios  2 года назад +1

      @@BenGodot When you say it randomly moves, is it just walking on its own, or more like sliding? If it is walking around, then the only problem I can think of is that the motion vector isn't getting zeroed properly when you release the movement buttons.
      Looking left and right should be handled with the rotate method we created that will rotate the character around the y-axis. I am realizing now, that if you converted this controller to first person, then you wouldn't be able to look up and down, so you would need to add that by rotating the camera around its local x-axis based on the y value from the mouse delta.
      If you set it up to look up and down, but not left and right, then you want to rotate the character on the y-axis using the x component of the delta, and rotate the camera on its x-axis based on the y component of the mouse delta.

    • @BenGodot
      @BenGodot 2 года назад

      @@sodarocketstudios thank you!

  • @Rghad97
    @Rghad97 Год назад

    25:59

  • @samsg1538
    @samsg1538 2 года назад +1

    isnt working no clue what i did wrong

    • @samsg1538
      @samsg1538 2 года назад

      followed all steps character wont move

    • @sodarocketstudios
      @sodarocketstudios  2 года назад

      What part isn't working? It's possible that I had a mistake in the video, or something changed between different versions of unity. You aren't the only that seems to be having problems, so it might help others if we can work through it.

    • @samsg1538
      @samsg1538 2 года назад

      @@sodarocketstudios im on unity 2021 so maybe thats why but i found a third person controller pack in the unity asset store so im using that now

  • @elonmusk4823
    @elonmusk4823 2 года назад

    pls put it in dicreption

  • @torres5015
    @torres5015 3 года назад

    18:18
    20:57