How to make a moving character in Unity

Learn the basics of moving objects in Unity as well as a few different approaches to fit your game needs.
First, you'll learn how to directly change the transform position of your object. Then I'll show you how to move your character using Unity's physics engine so you can correctly collide with other objects.
=========
PlayerController.cs: pastebin.com/muc8pBRr
❤️ Become a Tarobro on Patreon: / tarodev
=========
🔔 SUBSCRIBE: bit.ly/3eqG1Z6
🗨️ DISCORD: / discord
✅ MORE TUTORIALS: / tarodev
0:00 Intro
0:09 Create the script
0:20 Basic movement explained
0:48 Translate function
2:08 Move using velocity. Collide with objects
2:44 Adding jump using AddForce

Пікірлер: 69

  • @Tarodev
    @Tarodev3 жыл бұрын

    I've just created a Discord channel. Come drop in for a chat 😊 it's early days and I'm sure it will undergo many changes, but let's gooooo! discord.gg/GqeHHnhHpz

  • @noobcraft5712

    @noobcraft5712

    3 жыл бұрын

    I will get on my laptop then I will join

  • @noobcraft5712

    @noobcraft5712

    3 жыл бұрын

    :)

  • @raoulbest5395
    @raoulbest53953 жыл бұрын

    Amazing video! The quality is the thing that makes it shine, especially that great atmosphere and not a blank unity scene. Hopefully people who need will find this channel.

  • @Tarodev

    @Tarodev

    3 жыл бұрын

    Thanks Raoul! I like to try provide a feast for your eyes as well as your brain 😊

  • @durvids474
    @durvids4743 жыл бұрын

    Great stuff! Very concise and to the point and super well explained. Looking forward to more content!

  • @christianstrang
    @christianstrang2 жыл бұрын

    Great tutorials! Could you create one where you show how to setup your scene? I have the hardest time to make a scene look great in 3d and I like your setup a lot (textures you use, lighting, small particle effect), would really appreciate it!

  • @DeamonSorrow
    @DeamonSorrow11 ай бұрын

    to anyone who is dealing problems with running it, add the lines above void Update - it worked for me: private void Start() { _rb = GetComponent(); }

  • @animation_table
    @animation_table2 жыл бұрын

    Thanks for explaining it, this is great!

  • @TheMSKGC
    @TheMSKGC3 жыл бұрын

    i just came across your channel and seems u have amazing detailed stuff. I wanted to know how to make a game manager, but I wish if u do a detailed longer video on how to make all of managers scripts/event and and when and how to use them

  • @monkeysarestinky3106
    @monkeysarestinky3106 Жыл бұрын

    Amazing tutorial thanks!

  • @mnicodev
    @mnicodev3 жыл бұрын

    Nice! Could you make a tutorial about how to set the camera and post-processing that you used for this tutorial. Thanks!! :)

  • @sirplum4773
    @sirplum47733 жыл бұрын

    thanks ill try this out later

  • @soytet365
    @soytet3659 ай бұрын

    nice explain , thanks bong

  • @rhow9724
    @rhow97243 жыл бұрын

    Amazing video!

  • @pulkit6453
    @pulkit64533 жыл бұрын

    love you i wasn't able to understand a thing before and i was going to quit unity thanks to u !!

  • @Tarodev

    @Tarodev

    3 жыл бұрын

    Awesome. Glad you didn't quit unity 😊

  • @GAMEKING-vp9ye
    @GAMEKING-vp9ye3 жыл бұрын

    Very good, good luck, man 👍👍👍

  • @eatcakeomg
    @eatcakeomg Жыл бұрын

    you forgot to mention to go to the inspector of your player, expand the script and select your player in Rb otherwise this is perfect unless I did something wrong.. thank you so much edit: left and right is inverted???

  • @user-pu7pm9yc6w
    @user-pu7pm9yc6w2 жыл бұрын

    why doesnt it work for me no problems with the code but still doesnt work

  • @luatphung694
    @luatphung694 Жыл бұрын

    Supper great!!!

  • @brsdncr
    @brsdncr2 жыл бұрын

    I just discovered your channel and videos. Good job there! One question about this video though. Wouldn't it be better if you used FixedUpdate method instead of Update, when you're dealing with physics?

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    As a rule, you're right and it's generally better. For example if we were adding force it's better to place it in FixedUpdate (although that's what multiplying by Time.DeltaTime allocates for). For this scenario where we are setting the velocity directly there shouldn't be a difference either way. But generally, yes.

  • @noobcraft5712
    @noobcraft57123 жыл бұрын

    Good and also excited for discord server

  • @Tarodev

    @Tarodev

    3 жыл бұрын

    Check the pinned comment 😊

  • @noobcraft5712

    @noobcraft5712

    3 жыл бұрын

    @@Tarodev i am joining

  • @marcdirian6370
    @marcdirian63702 жыл бұрын

    HI and thanks for all your videos !! Anyone can tell me where to get thoses magnifics cubes Tarodev is using ?

  • @yummy8074
    @yummy807410 ай бұрын

    I followed the tutorial, did everything exactly like in the video, however after a few seconds of moving, the cube tips itself over. Has anyone even tried this tutorial before leaving a like and commenting how amazing it is?

  • @Tarodev

    @Tarodev

    10 ай бұрын

    Lock the rotation on the rigid body

  • @theblazingcharizard7446
    @theblazingcharizard7446 Жыл бұрын

    ok wait after the first step and i tested it by clicking W nothing happend

  • @keithpatience1233
    @keithpatience12337 ай бұрын

    how do make it so the player only moves left and right

  • @pulkit6453
    @pulkit64533 жыл бұрын

    also please make a video about character controller

  • @MRGOOSE-
    @MRGOOSE- Жыл бұрын

    how do i make the cube stay upright?

  • @radon4163
    @radon41632 жыл бұрын

    Quick question. whats the reason behind underline score behind the name of variables?

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    I use them for private variables, that way they don't share the same naming convention as local variables. If you can't tell exactly where a variable is coming from by its name, then you need to swap up your conventions 😊 Underscore privates is good c# convention. A lot of official unity devs threw the convention out the window, so unfortunately new devs didn't learn it.

  • @radon4163

    @radon4163

    2 жыл бұрын

    @@Tarodev Thanks for the explanation. I understand now

  • @ghoulyabani
    @ghoulyabani Жыл бұрын

    Sensei. I have a problem. My object which has PlayerController script is falling slowly. Why it's happening? How can I fix it?

  • @GameAdonis

    @GameAdonis

    Жыл бұрын

    Attach a collider to it

  • @MitoverNikita
    @MitoverNikita7 ай бұрын

    Where take this texture and material ?

  • @Topthelop
    @Topthelop Жыл бұрын

    i need help i typed in the code but it says error CS1022, CS0106, and CS8803 and i don't know how to fix this

  • @rj69617

    @rj69617

    Жыл бұрын

    same

  • @PanikGrafik
    @PanikGrafik2 жыл бұрын

    How did you get this nice smooth camera action?

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Cinemcahine was used here 😊

  • @VskutkuTrigen
    @VskutkuTrigen2 жыл бұрын

    we change velocity, Should not that be in Fixed update ? And also we dont need delta time when changing velocity ?

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Nope, setting velocity directly does not require Fixed Update. We don't need delta time as we're setting the value to a specific number and not ADDING a value to the current number. Hope that makes sense!

  • @gloomywoods2306
    @gloomywoods23062 жыл бұрын

    my biggest issue are controllers... no matter what I change in settings, sensitivity, deadzone, gravity, it's always snappy like GetAxisRaw....So I'm forced to use GetAxisRaw and somehow, magically have to figure out how to smooth this out.... which I couldn't figure out in the last few weeks....

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Smoothing can be done by adding some acceleration. So take your input, work out what velocity you'd like to be heading at full speed and then slowly build towards it. You can see how I do this in my ultimate 2d controller script, although it's a bit advanced

  • @user-pu7pm9yc6w
    @user-pu7pm9yc6w2 жыл бұрын

    i have a proble i need help

  • @user-pu7pm9yc6w
    @user-pu7pm9yc6w2 жыл бұрын

    i have a problem help me

  • @user-pu7pm9yc6w
    @user-pu7pm9yc6w2 жыл бұрын

    it doesnt work for me pls help

  • @maverickmeier9938
    @maverickmeier9938 Жыл бұрын

    Umm how do I make it so I can only jump once before hitting the ground?

  • @Tarodev

    @Tarodev

    Жыл бұрын

    Create a grounded check and do something like: if(_grounded){ // jumphere }

  • @LucasDickner
    @LucasDickner9 ай бұрын

    I did the tutorial exactly how it was but it keeps telling me that the variable _rb has not been assign and tells me that I probably need to assign the _rb variable in the inspector and I don't really know what to do since I am knew at this any help would really be apreciated.

  • @Tarodev

    @Tarodev

    9 ай бұрын

    If you click your object, you'll see on the inspector that there is an empty rigidbody slot. Drag the rigidbody component into that slot :)

  • @LucasDickner

    @LucasDickner

    9 ай бұрын

    Yep figured it out thanks for the reply but now I can't seem to be able to move my player, maybe I juste haven't implemented the whole code but I errased and juste rote the last parte idk if this ok but this is my code using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMouvement : MonoBehaviour { [SerializeField] private float _speed = 1; [SerializeField] private Rigidbody _rb; [SerializeField] private float _jumpForce = 200; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { var vel = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * _speed; vel.y = _rb.velocity.y; _rb.velocity = vel; if (Input.GetKeyDown(KeyCode.Space)) _rb.AddForce(Vector3.up * _jumpForce); } } I know you may not have time to look at it but if you do it would greatly be appreciated@@Tarodev

  • @LucasDickner

    @LucasDickner

    9 ай бұрын

    No i did do that I figuered that out by looking at another video but now I think the probleme is the script that i sended you please tell me if you see something wrong@@Tarodev

  • @user-tp1cj5fc2y
    @user-tp1cj5fc2y2 жыл бұрын

    How to make such beatiful cube and floor?

  • @thalos730

    @thalos730

    2 жыл бұрын

    textures, materials, and most importantly, use blender

  • @andubunea9627
    @andubunea96273 жыл бұрын

    Waiting for that discord server man

  • @Tarodev

    @Tarodev

    3 жыл бұрын

    I just set an alarm for tomorrow to do it. Thanks for reminding me!

  • @Tarodev

    @Tarodev

    3 жыл бұрын

    Alarm triggered! Check the pinned comment

  • @drakedragonwarrior1853
    @drakedragonwarrior18539 ай бұрын

    Cant drag script

  • @user-pu7pm9yc6w
    @user-pu7pm9yc6w2 жыл бұрын

    good video but i have a problem can some one help

  • @desuwestvlogs4127

    @desuwestvlogs4127

    Жыл бұрын

    what seems to be your problem?

  • @mudmubstudio879
    @mudmubstudio879 Жыл бұрын

    36

  • @Hex-.
    @Hex-.3 ай бұрын

    no explaining in the vid at all

  • @Tarodev

    @Tarodev

    3 ай бұрын

    Only person to have that complaint since its release. Might be a problem with the observer