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
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
3 жыл бұрын
I will get on my laptop then I will join
@noobcraft5712
3 жыл бұрын
:)
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
3 жыл бұрын
Thanks Raoul! I like to try provide a feast for your eyes as well as your brain 😊
Great stuff! Very concise and to the point and super well explained. Looking forward to more content!
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!
to anyone who is dealing problems with running it, add the lines above void Update - it worked for me: private void Start() { _rb = GetComponent(); }
Thanks for explaining it, this is great!
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
Amazing tutorial thanks!
Nice! Could you make a tutorial about how to set the camera and post-processing that you used for this tutorial. Thanks!! :)
thanks ill try this out later
nice explain , thanks bong
Amazing video!
love you i wasn't able to understand a thing before and i was going to quit unity thanks to u !!
@Tarodev
3 жыл бұрын
Awesome. Glad you didn't quit unity 😊
Very good, good luck, man 👍👍👍
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???
why doesnt it work for me no problems with the code but still doesnt work
Supper great!!!
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
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.
Good and also excited for discord server
@Tarodev
3 жыл бұрын
Check the pinned comment 😊
@noobcraft5712
3 жыл бұрын
@@Tarodev i am joining
HI and thanks for all your videos !! Anyone can tell me where to get thoses magnifics cubes Tarodev is using ?
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
10 ай бұрын
Lock the rotation on the rigid body
ok wait after the first step and i tested it by clicking W nothing happend
how do make it so the player only moves left and right
also please make a video about character controller
how do i make the cube stay upright?
Quick question. whats the reason behind underline score behind the name of variables?
@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
2 жыл бұрын
@@Tarodev Thanks for the explanation. I understand now
Sensei. I have a problem. My object which has PlayerController script is falling slowly. Why it's happening? How can I fix it?
@GameAdonis
Жыл бұрын
Attach a collider to it
Where take this texture and material ?
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
Жыл бұрын
same
How did you get this nice smooth camera action?
@Tarodev
2 жыл бұрын
Cinemcahine was used here 😊
we change velocity, Should not that be in Fixed update ? And also we dont need delta time when changing velocity ?
@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!
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
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
i have a proble i need help
i have a problem help me
it doesnt work for me pls help
Umm how do I make it so I can only jump once before hitting the ground?
@Tarodev
Жыл бұрын
Create a grounded check and do something like: if(_grounded){ // jumphere }
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
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
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
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
How to make such beatiful cube and floor?
@thalos730
2 жыл бұрын
textures, materials, and most importantly, use blender
Waiting for that discord server man
@Tarodev
3 жыл бұрын
I just set an alarm for tomorrow to do it. Thanks for reminding me!
@Tarodev
3 жыл бұрын
Alarm triggered! Check the pinned comment
Cant drag script
good video but i have a problem can some one help
@desuwestvlogs4127
Жыл бұрын
what seems to be your problem?
36
no explaining in the vid at all
@Tarodev
3 ай бұрын
Only person to have that complaint since its release. Might be a problem with the observer