No video

Unity 2D - RPG Tutorial 2024 - Part 02 Character movement

Please watch the video till the end, then do it yourself :D
Chapters:
00:00 - Intro
01:06 - Concept explanation
03:08 - Importing character sprite
06:05 - Creating the script file
09:00 - Coding the movement
25:35 - Testing the game
Links
Visual Studio Download: visualstudio.m...
Character Sprite: github.com/kiy...

Пікірлер: 235

  • @supraliminal283
    @supraliminal2837 ай бұрын

    for those wondering why their character is stuck under the tile map, when inspecting the character sprite, you must set its order of layer to 1.

  • @ivancamargod7819

    @ivancamargod7819

    7 ай бұрын

    thank you

  • @PankakesTheReal

    @PankakesTheReal

    5 ай бұрын

    YES thank you

  • @rijulduggal5584

    @rijulduggal5584

    3 ай бұрын

    "no one will help you on the internet" my ass

  • @j.d.zilkey7799

    @j.d.zilkey7799

    3 ай бұрын

    good man

  • @vipereaper

    @vipereaper

    2 ай бұрын

    Or in my case change the z value in position until you can see your character

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

    Full code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float moveSpeed; private bool isMoving; private Vector2 input; private void Update() { if (!isMoving) { input.x = Input.GetAxisRaw("Horizontal"); input.y = Input.GetAxisRaw("Vertical"); if (input != Vector2.zero) { var targetPos = transform.position; targetPos.x += input.x; targetPos.y += input.y; StartCoroutine(Move(targetPos)); } } } IEnumerator Move(Vector3 targetPos) { isMoving = true; while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon) { transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime); yield return null; } transform.position = targetPos; isMoving = false; } }

  • @Vazzible_gaming

    @Vazzible_gaming

    10 ай бұрын

    E bro nice, you've done a service.

  • @denzelvanderpasch2728

    @denzelvanderpasch2728

    10 ай бұрын

    thx because the script was not working for me

  • @russianraccoon5121

    @russianraccoon5121

    10 ай бұрын

    ily.

  • @mr_andie

    @mr_andie

    10 ай бұрын

    Thx

  • @Mori0451

    @Mori0451

    9 ай бұрын

    Thx

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

    Thanks for making these. I've gone through Unity's 3D and general Game Dev Tutorials which have given me such a good foundation and have been seeking tutorials for the 2D side of things & wanted a different style / perspective. I think you present your information well and I really appreciate your inclusion of Assets with the goal of hitting the ground running. Please keep creating educational content, your presentation is calm, informative and easy to follow. I think your mindset about teaching to think and not just providing the code, etc. is important and will really help people learn and create. Looking forward to finishing your series and whatever you have next

  • @epicgdev

    @epicgdev

    Жыл бұрын

    Thank you very much! It made my day!

  • @stickster44

    @stickster44

    10 ай бұрын

    I had to hard-code the move speed to get my player to move: public float moveSpeed = 2;

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

    I loved your explanations on each line of code and it really helped. I started putting comments on them in my own so I refer back and hopefully learn! Thank you for this!

  • @leinardesteves3987
    @leinardesteves39875 ай бұрын

    You are probably the best teacher in youtube when it comes to unity. You explain the purpose first, and then what each function does. Easy to remember, and gets people to understand the lesson. You also break them down into section. Amazing work!

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

    You should be doing movement in FixedUpdate, not Update. Otherwise your movement is going to be dependent on the user's computer power. A very fast computer will make your character move crazy fast. FixedUpdate solves this problem. At this point I would also suggest using the newer Input system, it just makes this stuff a lot easier.

  • @SentinalSlice

    @SentinalSlice

    Жыл бұрын

    How would someone go about fixing that. Just switch update with fixed update?

  • @RichardCalder67

    @RichardCalder67

    Жыл бұрын

    @@SentinalSlice Yup, anything that you don't want tied to the actual frame rate the computer will play at should go in fixed_update.

  • @welcomelittlefellow

    @welcomelittlefellow

    Жыл бұрын

    The deltaTime already takes care of that as although a frame update might be called sooner, the deltatime will be less and therefore the movement increment will be the same for any computer speed. if you want to simplify this code, I would get rid of the coroutine ;) `void Update() { input.x = Input.GetAxisRaw("Horizontal"); input.y = Input.GetAxisRaw("Vertical"); var targetPos = transform.position; targetPos.x += input.x; targetPos.y += input.y; transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime); } `

  • @BG-chain

    @BG-chain

    Жыл бұрын

    ​@@welcomelittlefellow (RU) все можно сделать еще проще (но я использую физическое движение), например: (EN) everything can be made even simpler (but I use physical movement), for example: private const float VSpeed = 250f; private const float HSpeed = 200f; private Rigidbody2D _physics; private void Awake() { _physics = GetComponent(); } private void FixedUpdate() { Movement(); } private void Movement() { _physics.velocity = transform.TransformDirection(new Vector2(GetHorizontal(), GetVertical())); } private static float GetVertical() { return Input.GetAxis("Vertical") * VSpeed * Time.fixedDeltaTime; } private static float GetHorizontal() { return Input.GetAxis("Horizontal") * HSpeed * Time.fixedDeltaTime; }

  • @PootisPenserPow

    @PootisPenserPow

    8 ай бұрын

    Morrowind taught me this, don't tie functions to framerate

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

    For those who are having trouble with movement even though your code was same as he is check the inspector window and check the "tag" if it's on player and when you input the script on the player component just add 1 on movement bellow the "script name"

  • @Orit10

    @Orit10

    9 ай бұрын

    How, I don't understand? Can you explain a little more?

  • @jaypalmer0616

    @jaypalmer0616

    9 ай бұрын

    Hi I'm not sure I follow, my code is exactly the same, I made the tag "Player" and then set movement to 3 and it still doesn't work.

  • @Aguyfrom225

    @Aguyfrom225

    5 ай бұрын

    Im having problems because input is ambiguous reference between unityengine and unityengine.windows Cs0104 error goes away if i type Input and not input

  • @angelkaki5707

    @angelkaki5707

    Ай бұрын

    @@jaypalmer0616 He is talking bout the Player Controller (script) you should see the Move Speed and set that to 1

  • @8bitenial313
    @8bitenial313 Жыл бұрын

    10 years working with Unity and it's the first time I see this approach to player movement outside of a "point and click" situation 😂 Maybe not the best solution for newbies, but nice and smooth "tiled" movement! 😉

  • @epicgdev

    @epicgdev

    Жыл бұрын

    I'm a noobies sharing what i learn :D I would love feedback thank you!!!

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

    Hey! Just discovered your videos, Thank you for your work Bro, very cool!

  • @epicgdev

    @epicgdev

    Жыл бұрын

    Cheers

  • @squarecircle1473
    @squarecircle147325 күн бұрын

    I think the best way to go about it is to learn c# first. I'd love making a game like this, but I'm currently only doing c#. Managed to make a text-based RPG console app with a leveling system and currently building a console-based library management system lol. I know its simple but I feel proud of it :D I am very much enjoying coding tbh. It's surprisingly creative in that you're actively building stuff, but its also abstract and requires problem-solving which I enjoy. My area of expertise is visual arts, so coding is a really nice supplement to that and game dev is a great way of bringing that together. I'm looking forward to learning more c# and getting more intuitive with it. I''ll come back to these lessons when ready. I think your teaching style is great! :)

  • @TOMMY_QIU
    @TOMMY_QIUАй бұрын

    Excellent Tutorial!Thanks from China. I can't find a good tutorial in my country's local social media, finally ,I find this. Very useful!

  • @cj.shot8616
    @cj.shot86163 ай бұрын

    Guys i wrote all the codes, but character doesn't move. Can someone help me?

  • @rafirizqullahramadhan6257
    @rafirizqullahramadhan625711 ай бұрын

    This video is really helpful for me, because i am a vocational high school students majoring in game development. Thank you so much for making this kind of video, keep doing it and i already subscribed you

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

    your explanations are really clear and easy to understand, thank you!

  • @epicgdev

    @epicgdev

    Жыл бұрын

    You're very welcome!

  • @MiguelPerez-ui2gy
    @MiguelPerez-ui2gy24 күн бұрын

    Hey man great video, you are truly a reference! Btw, in case you are interested, I suggest to replace the code: targetPos.x += input.x; targetPos.y += input.y; with this one targetPos += (Vector3) input; Its a one liner and considers the z coordinate of input as 0, which is exactly what we want.

  • @echomouser
    @echomouser4 ай бұрын

    Sick dude! Loved the explanations of the code! The math behind it is a little hard for me to grasp but I hope to understand it someday! :D Keep it up!

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

    This's amazing and I learned so much, thank you

  • @billal7185
    @billal718511 ай бұрын

    Good series so far! Nice level-flexible delivery

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

    Yep! My character stays under the floor and the solution given in the comments doesn't work. What worked is to put 1 in "Order in Layer" in the Additional Settings of the character. Also it is so small, I had to put x:4 and y:4 in the Scale option. Why is that? I followed all the video :( I know we sliced the background in 32x32 but idk...

  • @kira890

    @kira890

    6 ай бұрын

    we sliced the background 16x16, no? And the character 16x32? Anyway, I hope you found a solution! c:

  • @kizuma_
    @kizuma_7 ай бұрын

    If someone wants a "simpler", more elegant solution, it also stores the facing direction in case someone wants to animate the character accordingly: public class PlayerController : MonoBehaviour { public float moveSpeed = 5f; public Vector2 facingDirection { get; private set; } private void Update() { HandleInputs(); } private void HandleInputs() { Vector2 direction = new Vector2( Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical") ); direction = direction.normalized * moveSpeed * Time.deltaTime; transform.position += new Vector3(direction.x, direction.y, 0); facingDirection = direction.normalized; } }

  • @R1project0

    @R1project0

    7 ай бұрын

    Thanks man, works like a charm! how could you restrict movement to horizontal and vertical to avoid diagonal movement? I tried adding the same line shown in the tutorial but it doesn't work. I'd really appreciate it!

  • @kizuma_

    @kizuma_

    7 ай бұрын

    Yes! you could change your HandleInputs to private void HandleInputs() { Vector2 direction = new Vector2( Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical") ); if(direction.x != 0 && direction.y != 0) { direction.x = 0; // if you want to prioritize up/down movement, otherwise use .y } direction = direction.normalized * moveSpeed * Time.deltaTime; transform.position += new Vector3(direction.x, direction.y, 0); facingDirection = direction.normalized; } this way, if the player walks e.g. right/up, he will only walk up instead. @@R1project0

  • @pwndcappearl4235

    @pwndcappearl4235

    6 ай бұрын

    Thanks so much for this!

  • @pwndcappearl4235

    @pwndcappearl4235

    6 ай бұрын

    How would I animate the character sprites though?

  • @beeplushiee

    @beeplushiee

    6 ай бұрын

    @@pwndcappearl4235 This is my code and it seems to animate as it should using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float moveSpeed; public Vector2 facingDirection { get; private set; } private Animator animator; void Awake() { animator = GetComponent(); } private void Update() { HandleInputs(); } private void HandleInputs() { Vector2 direction = new Vector2(Input.GetAxisRaw("Horizontal"),Input.GetAxisRaw("Vertical")); if(direction.x != 0 && direction.y != 0) { direction.y = 0; } animator.SetBool("IsMoving", true); // change "IsMoving" to whatever your equivalent is direction = direction.normalized * moveSpeed * Time.deltaTime; animator.SetFloat("moveX", direction.x); // change "moveX" to whatever your equivalent is animator.SetFloat("MoveY", direction.y); // change MoveY" to whatever your equivalent is transform.position += new Vector3(direction.x, direction.y, 0); facingDirection = direction.normalized; } }

  • @matthewlavigueur6210
    @matthewlavigueur6210Күн бұрын

    Had to make an adjustment as my player wasn't moving (even though I had the exact game code). This fixed it for me. Added to variables: //set Vector 3 in scope private Vector3 targetPos; and replace your first if statment with this: if (input != Vector2.zero) { // Calculate the target position targetPos = transform.position + new Vector3(input.x, input.y, 0) * moveSpeed * Time.deltaTime; // Start moving towards the target if not already moving if (!isMoving) { StartCoroutine(Move(targetPos)); } }

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

    Nice tutos, thank you much. In Windows, just Ctrl+Mousewheel to zoom in or out directly in VS (maybe works with cmd on mac). M. D.

  • @epicgdev

    @epicgdev

    Жыл бұрын

    Thank you so much! I will be checking this out :D

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

    nice, looking forward for next tutorial

  • @epicgdev

    @epicgdev

    Жыл бұрын

    More coming soon! Thank you for the support!

  • @epicgdev

    @epicgdev

    Жыл бұрын

    hey @regejs, have you been trying to learn Unity?

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

    Can someone help me? It says vector2 does not contain a definition for GetAxisRaw

  • @Aguyfrom225

    @Aguyfrom225

    5 ай бұрын

    I got same problem

  • @spijkie83

    @spijkie83

    Ай бұрын

    I think you might have solved this already, but maybe for someone else with the same problem. Make sure you it's Input.GetAxisRaw, with capital I, Input refers to the input system from Unity, input with lower i refers to the variable you created with public Vector2 input;

  • @NoahElkins-pe4lz
    @NoahElkins-pe4lz4 ай бұрын

    Can Somone help me please I coded all the player movment in VS Code and applied to my player but i dont have an option to set the movment speed within inspector. Ive done multiple tutorials and this always happens to me i am unsure of what to do i cannot go any further I would really appreciate any help

  • @user-wx7dv4fn5m

    @user-wx7dv4fn5m

    2 ай бұрын

    This has happened to me and all you got to do is if it says moveSpeed you have to always cap the s in it

  • @josephbeau-reder813
    @josephbeau-reder813 Жыл бұрын

    Very good video, I downloead unity 1h ago, this is the best I could look for, ty man

  • @justicedunne6736
    @justicedunne67364 ай бұрын

    I have a question! I like the addition of not being able to move diagonally, however when I move up and down I can be holding the up arrow key and press the left arrow key to move left for a moment, then release and continue moving up. However if I hold the left arrow key down and try tapping the up or down arrow keys I stay only moving left. How can I fix this so that both directions act the same?

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

    Hey, quick question just want to make sure I download everything right (New to programming completely) Visual Studio comes with a lot of stuff to ask before installing, totaling to about 11.4GB of downloads. Is that the right path? It's a little long list of tools to write - don't want to clutter your comment box. P.S. If you're willing, consider opening a discord for questions, or just to converse. So stoked that you made this tutorial for us and I just want to make sure I follow it properly. Thanks,

  • @nemofeducis
    @nemofeducis10 ай бұрын

    I tried this code it worked for me: using System.Collections; using System.Collections.Generic; using UnityEngine; public class playerController : MonoBehaviour { public float moveSpeed; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { Vector3 playerInput = new Vector3(Input.GetAxis("Horizontal"),Input.GetAxis("Vertical"),0); transform.position = transform.position + playerInput.normalized*moveSpeed*Time.deltaTime; } } well I'm a noob so I don't know much. But i think it's fine for now

  • @itsbps

    @itsbps

    9 ай бұрын

    hi, im still learning C# and game dev thingy. and i want to ask, is that playeInput.normalized is to make diagonal movement have equal speed to horizontal and vertical?? thank you

  • @jojinodi3417

    @jojinodi3417

    6 ай бұрын

    @@itsbps Yes it'll make diagonal movement the same speed as the vertical and horizontal instead of adding them both for the diagonal movement

  • @ryuz__aki

    @ryuz__aki

    7 күн бұрын

    Thanks

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

    Hey, great video. I made everything until the 3rd NPC is created and now I try to understand everything. What is I don’t understand is why a Coreroutine is used and why it should be used? Isn’t it a bit overkill for such an easy game? Or is ist really important for further game development as an armature?

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

    Hey, I love the tutorials! Unfortunately, a little confused -- how am I supposed to actually move my character? -- I understand the code and why you have put each line, but when I run it, my character doesn't move and my assumption is because I haven't correlated any keys actually WITH movement. What keys are supposed to move the character? How am I meant to move it?

  • @dong-wang8257

    @dong-wang8257

    Жыл бұрын

    i had this issue too, look at the bottom left corner of unity, if it says "input axis Horizontal/Vertical not set up" then just go into your code on visual studio, and make sure that the letters H and V are capitalised in your input.x = Input.GetAxisRaw("Horizontal"); input.y = Input.GetAxisRaw("Vertical");

  • @vidyanshusamuel1905

    @vidyanshusamuel1905

    Жыл бұрын

    @Attyelep i am also having the same problem ? did each step correct... do you have any solution?

  • @shamstam

    @shamstam

    Жыл бұрын

    hopping on the bandwagon here, I can't figure out what is wrong. code is identical, letters capitalized. at a loss

  • @natirsagohuis4062

    @natirsagohuis4062

    2 ай бұрын

    I had the same issue, until I realized that in the while loop I wrote: targetPos = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime); instead it should be: transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime); I hope this helps.

  • @StoicMeditationsAtoZ
    @StoicMeditationsAtoZАй бұрын

    Love this tutorial , thanks for making it simple

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

    These are excellent tutorials

  • @BenitoBeni1414
    @BenitoBeni141411 ай бұрын

    Help my character is behind the background how do i fix this? Edit: i just added it i didn’t script yet

  • @noahollington9946
    @noahollington994610 ай бұрын

    just getting into game development with unity, had followed a tute for just using java. These videos are quite helpful. I would say, being a programmer I can follow you easy enough, but for people who don't know much, a bit more explanation if possible on the programming side of things would be appreciated - unless of course you were wanting us to go to someone else for a more detailed look of things.

  • @voidkon5581
    @voidkon55814 ай бұрын

    mr Epic Dev bro . good shit bro . best regards VoidKon.

  • @nhuttran9757
    @nhuttran975711 ай бұрын

    really helpful docs, but can you show me how to edit assets with nice borders like yours, when I drag over from the tile palette, the border just isn't pretty and there's a bunch of redundant colors

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

    25:31 can anybody tell me why do after I put the script onto the player the "move speed" is not there, somebody pls help

  • @anjubatus

    @anjubatus

    Жыл бұрын

    did you set your moveSpeed variable public or private?

  • @kuyashiix

    @kuyashiix

    7 ай бұрын

    @@anjubatus I'm having the same issue, mine was set to public. I switched it to private and it still won't let me add anything to "Move Speed" in the component script. Edit: I figured out the issue, I forgot some ; when writing the code. As someone who knows nothing about coding, this tutorial goes much too fast and assumes a lot. I really think the code should have just been a copy paste because even after the video is over, writing this code manually taught me nothing thanks to the explanation being vague or 'google this' being the explanation.

  • @Delta_Player_0ne
    @Delta_Player_0ne9 ай бұрын

    could anyone explain to me why input is delayed( character keeps moving for a little while after i press the button )

  • @zeyadhani2091

    @zeyadhani2091

    3 ай бұрын

    +1

  • @Delta_Player_0ne

    @Delta_Player_0ne

    3 ай бұрын

    @@zeyadhani2091 thank you

  • @Gameboy316-real
    @Gameboy316-real Жыл бұрын

    I need help it says isMoving = false; has I invalid token

  • @omarpokemon9626
    @omarpokemon96266 ай бұрын

    For people that the player is not moving be careful of writing IEnumerable insted of IEnumerator in the Move function. This happened to me and I was struggling for like an hour or so

  • @meow-pi3xu

    @meow-pi3xu

    6 ай бұрын

    omg ty for typing this i literally had the same problem 😭

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

    Thats exactly what i needed :) thanx bro

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

    I'm loving the tutorial so far, but while putting in "targetPos" I get an error. My C# dosen't detect "targetPos" Any reason as to why?

  • @Aguyfrom225

    @Aguyfrom225

    5 ай бұрын

    Delete the script and retype the entire thing. Make sure to fully delete old c script file. I had problems but this is a great solution

  • @its_smoggy3502
    @its_smoggy35025 ай бұрын

    when i drag player sprite it just shows as orange outline, doesnt show in game view

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

    Hi! been loving your videos so far, but I got a question. How do you make it so VSC shows you what's inside a function like in 22:30?

  • @epicgdev

    @epicgdev

    Жыл бұрын

    I need to make a video about that

  • @tonguyenducmanh
    @tonguyenducmanh5 ай бұрын

    thank u for created this series

  • @Zanarkand_0
    @Zanarkand_010 ай бұрын

    Damn. Spent an hour wondering why my character was jittering and it was because I was missing a " } "

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

    Great video, the only thing I wish that was in it was how you got all the autocomplete and other things ect.

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

    for those who get their character behind the tileset, go to 3d mode and move your character to the front a bit...

  • @motherfkingpopsicles

    @motherfkingpopsicles

    Жыл бұрын

    You shouldn't have to worry about your Z position in a 2D game. In a 2D game, the objects are rendered in the order you tell it to render. Unity simplifies this by letting you specify the 'Order in Layer'. Go to 'Additional settings' in your objects and look for 'Sorting Layer' and 'Order in Layer'. Leave all your objects on the default layer and just adjust the 'Order in Layer'. Example: My background and my sprite are both on the default sorting layer. The background's 'Order in Layer' is 0 and the sprite's 'Order in Layer' is 1.

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

    Can you tell me what extension are you using? thank you

  • @mushycorn4200
    @mushycorn42003 ай бұрын

    The move speed option isn't appearing on Unity and most of the commands aren't highlighting in my script. I'm not sure what I've done wrong, as I followed every step to the point I was copying

  • @inoshiibira3251

    @inoshiibira3251

    2 ай бұрын

    Remember to save the code. I was stumped with this issue for a while until i remembered it was because i forgot to save it. Also check for capital letters and making sure everything is timed correctly

  • @Vazzible_gaming
    @Vazzible_gaming10 ай бұрын

    This high quality, I've had coding classes, and I'm looking at things I've never even considered. You're not offering a simple movement script here, you're offer THE movement script. Like this is along the lines of what you should do to make it work professionally.

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

    hey i keep having error CS1061 stating that vector2 does not contain a definition for GetAxisRaw ! can you please explain how i can fix it thank you

  • @Aguyfrom225

    @Aguyfrom225

    5 ай бұрын

    Just delete old script file completely and retype it. I had same problem. Might be a space or a capital letter or noncapital letter

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

    It took me a half hour to spot that transform.position mistake in 22:30

  • @p.rasmitadora4731

    @p.rasmitadora4731

    7 ай бұрын

    I hope you would have elaborated I had to rewatch that part almost 20 times🤧

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

    Great Video

  • @sergiod4026
    @sergiod40269 ай бұрын

    Thank you for the lesson! The player moves with inertia. What causes it and how to get rid of it?

  • @sergiod4026

    @sergiod4026

    9 ай бұрын

    Found. This because "yield return null" allows coroutine to work a part of the next frame. So maybe better "yield return new WaitForEndOfFrame();"

  • @cloud252
    @cloud25210 ай бұрын

    I don't get how to move the player can anyone tell me , Please qwq

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

    The Code Is Malfunctioning. It doesn't recognize Some of the Code. It is showing me the following errors: Assets\Scripts\PlayerController.cs(7,13): error CS0246: The type or namespace name 'Vector2' could not be found (are you missing a using directive or an assembly reference?) Assets\Scripts\PlayerController.cs(28,22): error CS0246: The type or namespace name 'Vector3' could not be found (are you missing a using directive or an assembly reference?) Assets\Scripts\PlayerController.cs(28,5): error CS0246: The type or namespace name 'IEnumerator' could not be found (are you missing a using directive or an assembly reference?) Assets\Scripts\PlayerController.cs(7,13): error CS0246: The type or namespace name 'Vector2' could not be found (are you missing a using directive or an assembly reference?) Can anyone help me?

  • @BornToCode75

    @BornToCode75

    Жыл бұрын

    Please Help me with this...

  • @BornToCode75

    @BornToCode75

    Жыл бұрын

    I am using Visual studio version 2019.

  • @user-mo7jl2nl3v

    @user-mo7jl2nl3v

    Жыл бұрын

    @@BornToCode75 Hi! Have you added namespace UnityEngine? It looks like VS cann't find the declaration of Vector2 structure.

  • @nelsonrodriguez9646
    @nelsonrodriguez96466 ай бұрын

    When I type Vector2 the text does not turn green, and when I hover the cursor over it, there seems to be locks on the list of vectors. Can someone help with this?

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

    my character moves very slow and delayed

  • @nickreaper6624
    @nickreaper662429 күн бұрын

    How did you assign it to the movement keys???

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

    how to move?

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

    Amazing video, i'm quite new in game dev, im taking it as a hobby, but i'm learning a lot thanks to you

  • @Zl1_p

    @Zl1_p

    Жыл бұрын

    make the layer of the player 1 from the inspector

  • @epicgdev

    @epicgdev

    Жыл бұрын

    Hopefully it made sense in the next video when I talk about layers !

  • @NeoficialRo
    @NeoficialRo5 ай бұрын

    Thanks 🎉

  • @slightshortsmc
    @slightshortsmc6 ай бұрын

    thx for player movement

  • @Eboomer123
    @Eboomer1236 ай бұрын

    i might be dumb but i get about half a second of delay and about half of my key strokes are simply not output through the movement of my character. The code is the exact same as shown.

  • @EchnatonOne

    @EchnatonOne

    6 ай бұрын

    It might be the while loop. Try to run it without the while loop in the coroutine. I also have some problems with the loop.

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

    idk why but my character keeps moving upward. I even tried using the code from the video in the comments. I tried a different keyboard and everything. I'm really at a loss here.

  • @angelkaki5707
    @angelkaki5707Ай бұрын

    has anyone wonder how did he managed to get those clouds around the well??? coz its been 20 minutes and I cant figure out how the heck he did that xD

  • @Chaoslava
    @Chaoslava11 ай бұрын

    Hi, I've gone through most of this series of tutorials and so far have found it brilliant so thank you for making them! Is there any way have character movement be less.. "blocky" - my character moves one grid square at a time. Could it be more responsive? I've changed GetAxisRaw to "input.x = Input.GetAxis("Horizontal");", which allows for movement in a range between 0-1, but it still sometimes keeps moving after I release keys. And horizontal movement just doesn't feel right either. Thanks!

  • @Tony-cm8lg

    @Tony-cm8lg

    9 ай бұрын

    The way that the tutorial sets up the movement is to basically calculate a starting position and target position and then in the coroutine we calculate the direction and movement speed towards the target position. This means essentially that we aren't actually moving but we are saying "move in this direction by one unit" and the code executes that to move by one unit. Another way of doing this (a very simple way) is to use the following code private void FixedUpdate() { float x = Input.GetAxisRaw("Horizontal"); float y = Input.GetAxisRaw("Vertical"); input = new Vector2(x, y); transform.Translate(input*Time.deltaTime); } This allows you to move essentially however small a distance you want, not unit by unit

  • @VVorldAWarcraft

    @VVorldAWarcraft

    7 ай бұрын

    This code works much better and is easier to understand. How would I go about changing the move speed of this version of the code? @@Tony-cm8lg

  • @miwny

    @miwny

    6 ай бұрын

    @@Tony-cm8lg I've done this but I can't seem to change the movement speed on my Player?? Is there something I'm not seeing?

  • @Tony-cm8lg

    @Tony-cm8lg

    6 ай бұрын

    I think if you multiply by a constant you can control the speed of the movement. For example, input*Time.deltaTime*2 would move faster I think@@miwny

  • @br0ki547
    @br0ki5475 ай бұрын

    The type or namespace name 'vector3' could not be found (are you missing a using directive or an assembly reference?) please help

  • @Aguyfrom225

    @Aguyfrom225

    5 ай бұрын

    Capital Vector3. I have problems and what i did was delete the script in the microsoft viz and delete the script on unity. I started over and retyped everything and it works now

  • @conez4
    @conez43 ай бұрын

    Couldn't you simply do "if input.x+input.y > 0" for the Move functrion? why bother doing all that math when you already know how much you're transforming the body by (the values of input.x and input.y)

  • @jakubklacior1189
    @jakubklacior11894 ай бұрын

    Hey i have a question from where dis you get this assets and can i use for comercial use can you give me linki to it if you have

  • @Skirks_Husband
    @Skirks_Husband8 ай бұрын

    Hello, my character is showing only the outline not the entire character. How to fix this?

  • @JobbieCivanne
    @JobbieCivanne2 ай бұрын

    Do you have a document with the code completed and typed so we can compare

  • @siWIBU24
    @siWIBU244 ай бұрын

    Can I ask for a Playercontroller script?.....I've tried it many times but it always fails😅

  • @CodeGAMERQT
    @CodeGAMERQTАй бұрын

    Help i cant see the movment speed

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

    I have a problem :( it’s saying input axis vertical not set up in the console when I start it

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

    my character always appears behind the background, anyone know how to fix this? Edit: so after toggling a bunch of things, i figured out you just need to create a new layer on sorting layers, then put it behind the layer the player is on

  • @RIP857

    @RIP857

    11 ай бұрын

    A simpler way is in the inspector. Select your player, then in the inspector under Additional Settings there is "Order in Layer" setting. If you change that from 0 to 1, the player layer will be ordered after the background layer and will be visible in the scene.

  • @Tom-pq5se
    @Tom-pq5se10 ай бұрын

    hi, im trying to import the game character in the game scene. but when i trag it into the scene i am only able to see the border of the character and not the texture itself

  • @nikafvi

    @nikafvi

    9 ай бұрын

    Click at the character, then at 'order in layer' and put 1 instead of 0.

  • @the_tree_2010
    @the_tree_201010 ай бұрын

    For some reason, it is giving me 3 errors. any fixes?

  • @wizxk5849

    @wizxk5849

    9 ай бұрын

    same gives me an expression term error, a " ; expected error", and a "} expected" error even though i have the same code

  • @wizxk5849

    @wizxk5849

    9 ай бұрын

    nvm forgot a parenthesis for the while statement

  • @jeremyvert7018
    @jeremyvert70188 ай бұрын

    How did you draw the cloud tiles.after the first video

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

    Can I somehow "block" the character from moving diagonally?

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

    Hi! Loving the tutorial so far. I have the same code as you, but I can’t move my character. Is there a specific reason for this?

  • @epicgdev

    @epicgdev

    Жыл бұрын

    A lot of people said that the issue was with capitalizing correctly the variables. like MoveX

  • @ClipDip74

    @ClipDip74

    Жыл бұрын

    @@epicgdev I think I did, I checked through all of my code. Thank you so much for the reply though, your tutorials are extremely good for learning. I ended up using another video by “BMo” and used the movement system he used. I loved your video on creating backgrounds, I was up until 4 in the morning creating my map :) I also used your method for making animations

  • @bratkirby
    @bratkirby9 ай бұрын

    how do you get the clouds to look so good

  • @sebastianbryndziar5230
    @sebastianbryndziar52307 ай бұрын

    why is my character moving just left and right?

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

    How can I turn this code into a pixel perfect movement?

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

    I have a question... Like why my character is going wildly like he move like the flash. Is there any solution?

  • @invisi6l339

    @invisi6l339

    Жыл бұрын

    🤣🤣lmao

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

    25:43 What keyboard key did you press?

  • @WarthunderLemon
    @WarthunderLemon8 ай бұрын

    my charakter is walking to the left autom. What do I do?

  • @user-lh6vp4ro3w
    @user-lh6vp4ro3w6 ай бұрын

    and what about i want to create my own character?

  • @Cyber-Gyn
    @Cyber-Gyn Жыл бұрын

    I'm a beginner, please send the code here, I wrote the same as the video, but for some reason it didn't work I get an error Assets\Scripts\PlayerController.cs(35,75): error CS1513: } expected

  • @aleksi2627

    @aleksi2627

    Жыл бұрын

    It's likely that you made some kind of mistake. C# is very strict. I'm extremely new to programming, but I THINK that your error means that the problem is on the row 35 and 75? So check those and also check the rows just before them, so 34 and 74.

  • @okboomer1951

    @okboomer1951

    Жыл бұрын

    have you fixed it? i got the same problem but on 42,112 and that aren't the code linec beacuse i don't even have that many

  • @tadijaristic9500
    @tadijaristic95008 ай бұрын

    My code is the same as yours and i did everything as you, but my character isnt moving

  • @p.rasmitadora4731

    @p.rasmitadora4731

    7 ай бұрын

    It is due to at 23:29 he changes targetPos to transform.position

  • @hyperspeedz7135
    @hyperspeedz71359 ай бұрын

    I need help I can’t find the script in Visual studio

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

    For some reason my input is inversed.

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

    is there anyway to polish the movement

  • @Pipi0-0-7
    @Pipi0-0-7 Жыл бұрын

    hi, the movement of the player is delayed, what should i do?

  • @nydaarius6845

    @nydaarius6845

    9 ай бұрын

    i have the same problem. did you find a way to fix it?

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

    nvm it seems to work now but im moving too fast

  • @saifkhaled1914
    @saifkhaled19145 ай бұрын

    Why did you choose coroutine function?

  • @145Jamie

    @145Jamie

    5 ай бұрын

    I'm wondering the same, much easier ways of moving a 2D character up and down. This just hurt my brain

  • @TemplorKnight
    @TemplorKnight3 ай бұрын

    Oh hey its like java... oh hell its like java i need to learn the library

  • @qwanton8632
    @qwanton86328 ай бұрын

    wtf is IEnumerator, cuz none of my software ( vs, unity , ...) recognize this as a valid thing