#2 | CREATING OUR FIRST C# SCRIPT! 🎮 | Unity For Beginners | Unity Tutorial

Sdílet
Vložit
  • čas přidán 28. 08. 2024

Komentáře • 221

  • @Aario_TH
    @Aario_TH Před měsícem +6

    I'm no pro in programing i just know python but when i was done and tested the movement my mind was blown i LOVE this

  • @md.jannatulnayem4328
    @md.jannatulnayem4328 Před 2 lety +25

    Make sure you keep making these videos Dani...I'm gonna need them a lot in my GamDev journey ❤️

    • @Dallanimation
      @Dallanimation Před měsícem

      How goes your progress on your journey?

  • @solarwindstudio
    @solarwindstudio Před rokem +11

    This really helped me. Thank you for sharing this. The way you teach is very comforting. You take your time, give off a very positive vibe, and you are enthusiastic. This is exactly what I needed. Please keep making more videos!

  • @Dani_Krossing
    @Dani_Krossing  Před rokem +2

    "MY CODE ISN'T THE SAME COLOR AS YOURS?"
    I get that ☝ comment quite often, so let me tell you how to fix it. 🙂
    In the #1 lesson, I mentioned that I would link a "how to install and setup Unity" video in the description, and in that video I show you:
    - How to install Unity
    - How to set up Intelisense in Visual Studio (👈 this is what you skipped)
    - How to set up Unitys interface
    Here is the link again: czcams.com/video/ewiw2tcfen8/video.html&ab_channel=DaniKrossing
    ALSO,
    You are more than welcome to write a comment if something isn't working, and I will see it. 🙂 Just make sure that if you are writing about "code not working", that you INCLUDE the code. 😂
    Writing a comment that simply says "My code doesn't work, and I copied your code exactly", won't do any good. 😅 Because I can with 100% guarantee you that you made a typo, and I'd love to help find it. 🙂 But to help you and find the typo, I need to see your code...
    And if you write a comment for me to help you, make sure to let me know if it worked. 🙂 9/10 times when I reply and help people, they will ghost me after I let them know what their typo was, and I won't get the satisfaction of knowing whether or not I wasted my time replying. 😅

    • @mikemike5666
      @mikemike5666 Před rokem +1

      you should pin this message

    • @flerd_fp
      @flerd_fp Před 6 měsíci

      thx for the tutorial ;)
      this comment helped me, so thank you for taking the time.. ;) it was so frustrating not to have the same colors / highlights / notifications as you do in this video.. and i noticed that for some reason unity didn't save the setting of the "External tool" >> "External script Editor".. and somehow it started VS without the "Attach to Unity" function.. i set it up again in unity.. restarted both unity and VS.. and now it works ;)
      if you read this, i think too that you should pin this message ;)

  • @mintcrisp94
    @mintcrisp94 Před rokem +5

    So nice of you to take time out of your busy schedule running space X and Tesla to teach game design, Elon :) very cool.

  • @dcry1003
    @dcry1003 Před 2 lety +8

    Ive already learned a lot from your html and css tutorials and this is just what i need thank you dani! Much love from the philippines💕✨

  • @danijel4380
    @danijel4380 Před rokem +3

    I love the way you explain the tiny details, thanks. BTW Elon Musk looks like you

    • @DannyBoy443
      @DannyBoy443 Před rokem +1

      The topic, the post and the reply are ALL by Daniels lol. #OwnIt.

  • @wirepirate343
    @wirepirate343 Před 8 měsíci +1

    I am in college learning Web Design but have always wanted to make my own game. When you said Unity uses C# I just thought alright another one to learn! I thought learning Javascript, HTML, CSS, PHP, and now C# at the same time would be harder! Thank you for this tutorial!

  • @sadeepthajayathilaka3144
    @sadeepthajayathilaka3144 Před 9 měsíci +4

    This video series is very informative and engaging. I appreciate your hard work and dedication to creating high-quality content.

  • @hugomejia7826
    @hugomejia7826 Před rokem +2

    Dani, your videos are really made for beginners, so well explained !! :D I got experience in web development and some of the programming part its a bit trivial for me, but you really do help me understand Unity better , thanks for the effort !

  • @silentglovesgaming
    @silentglovesgaming Před 2 lety +1

    Just want to say that I'm watching this as a Software Engineer with 20+ years of experience. I have no experience with C# or Unity, but to every time you asked "does this make sense?" The answer is yes, but I am probably slightly biased. 😂

  • @ParaSempreJogador
    @ParaSempreJogador Před 11 měsíci +1

    Man, how I got so motivated just for move the rectangle from one side to another it's beyond me, lol. Anyway, many thanks for all the help that you are providing us!

  • @Atenvardo
    @Atenvardo Před 3 měsíci

    Great series Dani "Rewatching it for the second time", I would love to see you get back into Unity, something like a Unity 6 course or such. Great, clear and open explanations as always!

  • @mayamarshel9957
    @mayamarshel9957 Před 2 lety +5

    These have been super helpful thank you for taking the time to make them comprehensible and in depth. I really appreciate it!

  • @elisakrings6624
    @elisakrings6624 Před rokem +1

    First time someone explained the words and terms used in the default script ! Thank you so much for these videos ! Love it, i finally understand a tiny bit of coding ! :DD It's all thanks to you c:
    Hope you have a great day

  • @the-great-mizuti
    @the-great-mizuti Před rokem +1

    Thank you!! Your explanations are great. These videos are really helping me to wrap my head around Unity and C#, so I don't feel so lost and confused when staring at the code.

  • @JoeRowland90
    @JoeRowland90 Před 5 měsíci

    Thank you. This tutorial is still 100% relevant for anyone checking it out in 2024.
    Acquire no longer make Way of The Samurai games.
    This is the only reason I am learning to do this.
    I am going to try and make a side scrolling 2D version of their game.
    They have a several ending, choices matter system though, that will be too complicated for me at this stage.
    If I can just get a side scroller working, I will be super happy lol.
    I mean it's not like I am going to copy their game. Just the concept of it.
    Because it was IMO the best idea anyone ever put into a game. Especially for replay ability.
    After that I will just keep learning.

  • @azlath
    @azlath Před 2 lety +6

    Awesome video! I like how in your videos you take the time to give us a general idea how things work and what they do, instead of just telling us to copy the code you are using as is, just because... Thank you! That said, I've seen some videos where they recommend using Velocity instead of AddForce for horizontal movement in a 2D platformer. I wonder what do you think about that?

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety +6

      Hi Mike, and thanks! 😊 I do my best to make things understandable, so I'm glad to hear you think I succeed.
      To answer your question regarding "AddForce vs Velocity"... Comparing AddForce and Velocity, is like comparing a bike and a scooter. You really just wanna go with the one that "feels right to use".
      AddForce and Velocity behaves in two completely separate ways, and there isn't a "right choice" since it really depends on the type of game you are making. AddForce adds "extra force" to the existing force of an object, where as Velocity completely overwrites the existing force.
      The reason Velocity is popular in most 2D games, is because the developer likes to have more control over how the player moves in their script. Velocity based movement starts out feeling extremely static and sudden, but allows you to "build your way up" to make the movement smoother. 🙂 Essentially giving you more control, which is why Velocity is used more.
      Where as AddForce starts out feeling extremely chaotic, and as if the player is sliding on ice. 😅 And it requires a lot of "adjusting" through scripts, physics material, or linear drag, just to regain control over the players movement. So instead of "building your way up" like you do with Velocity, you instead need to "build your way down" hehe.
      But again... It really depends on how you want your game to feel, and the only one who knows that is you. 🙂 AddForce isn't "wrong to use", it just behaves differently. 😊
      Personally, I mostly use Velocity when making 2D games. However in my latest 2D platformer I'm working on, I'm using AddForce because I want the "sliding on ice" feel for that particular game. 🙂

  • @zoejoe7709
    @zoejoe7709 Před 2 měsíci

    You explained details more than my program professor did.

  • @zkatzos
    @zkatzos Před 5 měsíci +1

    Thanks for the video Dani, there's a lot of Unity beginner tutorials out there, but none explain the coding as simply and clearly as you do! Appreciate it!!

  • @JakeSimmer
    @JakeSimmer Před rokem +1

    Awesomeeee!! I had at least 4 errors, typing errors of cause... - instead of _ , 2d instead of 2D, forgot a ; somewhere.... and cAps where they shouldn't be.... Fortunally the compiler lists in which line the error is in, and a little Googling of cause LOL, I had a cool block moving from side to side, can't wait to add up and down and after that some rotation. After soooo long, my programming journey finally has a decent beginning, thanks Dani!

  • @abdulaitimbo3757
    @abdulaitimbo3757 Před rokem +1

    Thanks a lot for your teaching videos (17). They are very simple to understand. I appriciate your videos a lot.

  • @rj_enoz
    @rj_enoz Před 12 dny +1

    I learn in this video :
    Termology :
    Ide = Text Editor
    Learn :
    NameSpace =
    +GreyOut (Not Using it)
    +White (Using it)
    Code that is already created before, and to reference it to our own code
    -Document and the naming convention (on public class) must be the same
    Summary on NameSpace :
    NameSpace -> Class -> VoidStart, VoidUpdate
    New Method = Yellow(Godot is Function)

    • @Dani_Krossing
      @Dani_Krossing  Před 11 dny

      IDE and Text Editor aren’t entirely the same thing 🙂 An IDE is a more complex version of a text editor, which has more complex features.

  • @TheOneAndOnlyTed
    @TheOneAndOnlyTed Před rokem +1

    I may be the only one with this problem, but I thought I'd come back anyways since I didn't solve this until episode #8.
    If you're not getting that "Unity Message | 0 references" above some of your lines and things aren't getting highlighted the same and giving you some of the same suggestions as the video, you may need to change you External Script Editor. Go to Edit> Preferences> External Tools and then in the drop down menu for External Script Editor, change it to Microsoft Visual Studio (or whatever you're using I guess but I'm still new and don't know how other applications interact)
    capitalized because the references weren't popping up and I'm terrible at typing.

  • @mitoroskokoros589
    @mitoroskokoros589 Před rokem +1

    this video was the first ever video that helped me out thx

  • @darkpyroftwreal9610
    @darkpyroftwreal9610 Před rokem

    Oh my gosh i was so happy when i just moved the cube left and right you are AWESOME!!!

  • @topborec128
    @topborec128 Před 6 měsíci +2

    wow your tutorial is so helpful thank you

  • @Julebstube
    @Julebstube Před 4 měsíci +1

    I just began this with the newest version, and could not find the 2D object. But I found out, if you start a 3D project you have to add the 2D sprite in Package manager. Now my rectangle is sliding all over the place :-)

  • @lovefamily9422
    @lovefamily9422 Před 4 měsíci +1

    I love your video, really give us the full picture of this

  • @kabhikachambala3392
    @kabhikachambala3392 Před 2 lety +1

    Ohooo! Again.💪 I like the way you do. It is real classroom with the lowest fee of MBs, subscribe, like and share. In Swahili we say "ASANTE" (thank u)

  • @justchris846
    @justchris846 Před 11 měsíci +1

    Thank you for your videos.

  • @becookieacookiegod
    @becookieacookiegod Před 3 měsíci

    I like programming! 2:16

  • @MattDoesSound
    @MattDoesSound Před rokem +1

    Thanks for the excellent tutorial! I'm totally new to programming but the dots are slowly connecting...

  • @davelordy
    @davelordy Před rokem +1

    Great videos so far 👍 . . . but . . .
    What I hate about coding videos . . . you have the expanse of a HD 16:9 screen, yet everything is shoved up against the left edge, the code and your video feed, why not move your feed to the right, as well as zooming in on the code . . . as it is it's unwatchable on mobile and annoying on a desktop computer. I mean, you must admit it's silly to have such a large canvas, but when you are typing at 14:55 for some reason it needs to be hidden behind the video feed of your face ?

  • @zyzz5070
    @zyzz5070 Před rokem +2

    hello sir, I am having problem. Everything is working fine, except when I let go of keys, it still continues to go in the direction and if I hold the key, movement speed is adding up. Can you please help?

    • @BonesOfficial_
      @BonesOfficial_ Před 2 měsíci

      Just do the tutorial again, if it still isn’t working you can go on forums or another tutorial

  • @GregamoNintendo
    @GregamoNintendo Před 2 lety

    Awesome video, thank's for the help!

  • @loganharris7584
    @loganharris7584 Před 8 dny

    I followed along until we opened visual studio and my code doesn’t have the same colors as yours, as well as when I enter the rigidbody text it doesn’t pop up and complete it into a thing like it does for you. Yours seems to be set up differently idk if it’s a new version or just set up different and I’m at a loss. Complete beginner never programmed in my life. Just a dream of making simple games and a desire to learn

  • @Mhooodie
    @Mhooodie Před 8 měsíci

    how does it know to use A & D and left and right when it wasn't clarified? I know im probably getting caught up on small things but if you could do a more detailed breakdown of what the line by line is doing that would be great! I haven't finished the series yet though so maybe I just haven't seen you go into detail yet. Amazing video, thanks!

    • @Dani_Krossing
      @Dani_Krossing  Před 8 měsíci +1

      Unity has a build in setting for those buttons, which you can see for yourself by opening the input settings. I don’t have Unity in front of me atm… but you might find it under preferences, or project settings.

  • @notmalicious
    @notmalicious Před 3 měsíci

    This helped so much, but for some reason the code that appears by default in my Visual Studio script isn't working or looking the same as it should be according to your screen

  • @zakiro2599
    @zakiro2599 Před rokem

    Thanks bro, it help me learn unity

  • @Fr34kDj
    @Fr34kDj Před 5 měsíci

    Thanks for your work😊

  • @pontustve1thegoldendragon483

    Intresting and thx

  • @counterfeitUser
    @counterfeitUser Před rokem

    If the object is still moving after input (which was a problem I had) you can add the following into an else statement:
    "_rb.velocity = Vector2.zero; "
    As I am just starting out, not sure which is best but you can do it either example below:
    example #1 (without calculate movement variable):
    void Update()
    {
    // Get input axes values
    float inputHorizontal = Input.GetAxisRaw("Horizontal");
    float inputVertical = Input.GetAxisRaw("Vertical");
    // Apply movement only when input is detected
    if (inputHorizontal != 0 || inputVertical != 0)
    {
    _rb.velocity = new Vector2(inputHorizontal * _walkSpeed, inputVertical * _walkSpeed);
    }
    else
    {
    // Stop movement when no input
    _rb.velocity = Vector2.zero;
    }
    }
    example #2 (with calculate movement variable):
    void Update()
    {
    // Get input axes values
    float inputHorizontal = Input.GetAxisRaw("Horizontal");
    float inputVertical = Input.GetAxisRaw("Vertical");
    // Calculate movement vector
    Vector2 movement = new Vector2(inputHorizontal * _walkSpeed, inputVertical * _walkSpeed);
    // Apply movement only when input is detected
    if (inputHorizontal != 0 || inputVertical != 0)
    {
    _rb.velocity = movement;
    }
    else
    {
    // Stop movement when no input
    _rb.velocity = Vector2.zero;
    }
    }

  • @becookieacookiegod
    @becookieacookiegod Před 3 měsíci

    Doesnt work (side movement) tells me: ( ! ) ArgumentExeption: Input Axis Horizontal; is not setup.

  • @nehapatel9167
    @nehapatel9167 Před rokem

    Thank You

  • @gollem1186
    @gollem1186 Před 3 měsíci

    This tutorial has really helped me understand C#, however I am having problems with unity in which my Input Axis Horizonal is not working or "set up" I've tried changing things in project settings but nothing is working, could I have written something wrong in the script?

  • @mikehynz
    @mikehynz Před rokem

    Fantastic video.
    Question: wouldn't 'Systems. Collections' already include "Systems.Collections.Generic'?
    Why is this not redundant? Thanks

  • @Soulsphere001
    @Soulsphere001 Před rokem

    One thing I find odd about name spaces in Unity is... If I understand you correctly, name spaces in Unity are sort of a combination of C++'s "#include" for including libraries and "using namespace" for reducing the amount of typing required?
    EDIT: Also, I know you're just throwing something together quickly, but (_inputHorizontal != 0) bothers me, because you're doing that with a float type. Though I suppose it should be pretty accurate. I guess if you want to check if it's exactly 0.0, that isn't terrible.

  • @woodsman9427
    @woodsman9427 Před 4 měsíci

    hello i know this is hold but I keep on having errors either in unity editor.sceneview or in my visual studio and I am wondering if you could help me?

  • @no.one12325
    @no.one12325 Před rokem

    for some reason I just cant get it right. I copyed everything line for line but it dosent work for some reason

  • @dino3649otherchannel
    @dino3649otherchannel Před rokem +1

    Hey Hope U are good I just Wanted to Ask is my code right?Because it is Showing Errors For me Here is my code using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Test : MonoBehaviour
    {
    Rigidbody2D _rb;
    float _walkSpeed;
    float _inputHorizontal
    // Start is called before the first frame update
    void Start()
    {
    _rb = gameObject.GetComponent();
    _walkSpeed = 5.5f;
    }
    // Update is called once per frame
    void Update()
    {
    _inputHorizontal=Input.GetAxisRaw("Horizontal");
    If (_inputHorizontal != 0)
    {
    _rb.AddForce(New Vector2(_inputHorizontal * _walkSpeed, 0f));
    }
    }
    }

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      At a quick glance I found 3 errors in your code. One in your fields, and two inside your Update().
      I will let you check your code again, since it will help you in the long run to practice recognising errors. 🙂

  • @MrEjecT
    @MrEjecT Před 2 lety +1

    Hi, thank you for the videos. I hope you can help me with my question.
    I followed the tutorial exactly, even set my screen up exactly like yours is, however...
    The namespaces in my script did not change color when I deleted their counterparts when we were reviewing the information that comes before writing, and I don't know if that's where the problem began. :P
    I'll be posting code as a comment.
    I added Rigidbody2D to my player object and I changed the interpolate, collision detection and gravity scale like I saw you do. The only thing I did differently was drag and drop the script over to the player.....................
    okay I had tried renaming my script and the public class to see if it fixed it but I changed it back to Test and it's working? See ya next timeee thank you

    • @beeholland5946
      @beeholland5946 Před rokem

      Remember they have to be exactly equal (if you rename it in Unity it won't rename it in the code.)

  • @s4d0wsc0re7
    @s4d0wsc0re7 Před 2 lety

    my monobehavior in not being picked up i have tryed everything to fix this it thay wont go blue only yellow on start up and stay that way

  • @anasstuff1551
    @anasstuff1551 Před rokem

    bro ur the best

  • @fliegendesalami
    @fliegendesalami Před 2 lety

    Hi, I just tried to follow your instucktions for moving the Player but the class MonoBehavior doesnt work. By that I mean it doesnt change color no matter what I do. Can anyone help me on this one pls?

  • @filipondrek868
    @filipondrek868 Před 9 měsíci

    Hello I am trying to follow your action however If I am writing any code there is no extra text to choose. I have to type all manually. Please could you let me know what I have to do ??

  • @Whatisgoingonherebro
    @Whatisgoingonherebro Před 2 lety

    I dont know why but mine jsut stay Misenllaneous Files and not changing to Assembly C sharp. can you tell me how to chaange to Csharp

  • @obamasmith420
    @obamasmith420 Před rokem

    For me, the code in vs is in white without any color and there are yellow borders on the top and bottom.
    Is there a way to change it to look like yours?

  • @keilank
    @keilank Před 2 lety

    For whatever reason, the program won't run until I "fix" my if statement. Here is exactly what I have written:
    _inputHorizontal = Input.GetAxisRaw("Horizontal")
    if (_inputHorizontal != 0)
    {
    _rb.AddForce(new Vector2(_inputHorizontal * _walkSpeed, 0f));
    return;
    }
    and here is the error message that I recieved:
    [18:16:10] Assets\Scripts\Test.cs(23,58): error CS1002: ; expected
    Regardless of wether or not I can get this fixed, thanks for the great tutorial, and I can't wait to watch the rest of the series! 😄
    (Edit: Never mind, it turns out that I just forgot to add a semicolon at the horizontal input line 🤣. Everything is working perfectly now!)

  • @Nerdathon
    @Nerdathon Před 2 lety

    I dont know why but when i type in any type of "Rigidbody, or Rigidbody 2d," it Never changes color or works! in the box of things under it it only says things like readonly record or ref, explain why please

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      One of these are causing it:
      1: You made a typo or deleted something from the file, and now intellisense doesn’t suggest it because you aren’t allowed to write the RigidBody there.
      2: You didn’t set up intellisense yet (meaning you skipped the video, I mentioned at the start of lesson 1)
      3: You forgot to add the script to your game object inside Unity, so the script doesn’t get run.

  • @lizmontgomery3767
    @lizmontgomery3767 Před 2 lety

    Is it ok if my start and update are yellow and my system collections and system collections generic are white??

  • @abyanmahya5184
    @abyanmahya5184 Před 2 lety

    Thanks bro

  • @Mewoox
    @Mewoox Před 2 lety

    why clicking on get component, it dosent appear the "()"part?

  • @ushas3349
    @ushas3349 Před rokem

    Hi Dani,
    My first game of moving the player by left and right key works. But the player object keeps moving just with one left key press and starts moving continuously right when I click right arrow key once! I think I need to give some resistance to the movement.
    How do I do that?

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      It depends a lot on how your movement is programmed. But yes, adding some "linier drag" inside the RigidBody2D component, on your player, would help slow down the movement if you are using AddForce() movement like in this video.
      Another solution is also to add a PhysicsMaterial to your player, and then include friction in it.
      Or, you could create an else condition in your code, to slow or stop your player movment, when not pressing left or right.
      There are a few ways to get the same answer 🙂

  • @jacobh1833
    @jacobh1833 Před 2 lety

    I haven't watched your entire series, but is there a way to get a print/printf or other visual confirmation of events or keystrokes through Unity?

    • @noahlundie700
      @noahlundie700 Před rokem +1

      you just do print(""); and it will show up in the console

  • @nolppo
    @nolppo Před 2 lety +1

    Thank you. I definitely learned a lot from your tutorial. keep going

  • @gvgpandaaaaa
    @gvgpandaaaaa Před rokem

    Visual studio won’t open

  • @Kazmir1542
    @Kazmir1542 Před rokem

    Great Video but I have an issue. When I type any code into the visual studio nothing lights up. Not sure why. Even when i pull up the window my Monobehaviour is just white. Any tips?

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      Make sure to follow the video I linked in the description of episode 1 🙂

  • @thomaslikesgames5934
    @thomaslikesgames5934 Před rokem

    It says: Fix all compiler errors if i try to test it. Can anyone help?

  • @cb_sp5022
    @cb_sp5022 Před 2 lety

    nice video😁

  • @Kai-kl6fe
    @Kai-kl6fe Před 2 lety

    Hi! When I try to move the player I get the following message:
    ArgumentException: Input Axis horizontal is not setup.
    To change the input settings use: Edit -> Settings -> Input
    Test.Update () (at Assets/Scripts/Test.cs:25)
    Can you please help?

    • @Kai-kl6fe
      @Kai-kl6fe Před 2 lety

      Never mind. I wrote Horizontal with small "h". Thanks for these tutorials!

  • @Icebreaker070890
    @Icebreaker070890 Před 2 lety

    On the Visual Studio Code it seems that I have different colors on the coding text + that I don't get the dropdown box with shortcuts like you do. I don't know why it is and was hoping you could help. For example it doesn't pop up fo me the dropdown when I enter Rigid which shows in your video "Rigidbody2D" is this some form of plugin maybe?

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      You need to go into Unity, and assign VS as your default editor. I show how to set up Unity and VS in the video I linked in the description of the first video in this course. 🙂

    • @Icebreaker070890
      @Icebreaker070890 Před 2 lety

      @@Dani_Krossing Thanks! Did the trick, one more questions, can you save your layout in Unity (Hierarchy, inspector, project,etc) so every time you create a new project it keeps the same layout ?

  • @deepakdeepu8366
    @deepakdeepu8366 Před 2 lety +1

    hi bro i did same exact how u did and no errors but my square isnt movig at all

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety +1

      My best bet is that you missed a step, or have an error that just doesn't show in the console. 🙂 99% of the time that is the reason why people can't get it working, even if they say they don't have errors in their code. 😉

    • @deepakdeepu8366
      @deepakdeepu8366 Před 2 lety

      @@Dani_Krossing bro i did exact same from beginning but still didn't work

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      @@deepakdeepu8366 ​ If you had followed it step by step without making mistakes/typos, then it will work. :) I can guarantee you that you made a mistake somewhere along the way ;)

    • @jacobh1833
      @jacobh1833 Před 2 lety

      I've got the same issue, did you ever figure it out?

  • @tarek_maza
    @tarek_maza Před rokem

    Link to download the assets used in the projects is missing

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      It's linked in the bottom of the description 🙂

  • @diablotempest103
    @diablotempest103 Před 2 lety

    for some reason when i installedvisual studio and opened the test file it showed miscellaneous files instead of the asset c sharp do you know why?

    • @Ryans_3D
      @Ryans_3D Před rokem

      Did you manage to fix it?
      I can tell you how

  • @eccsubs2179
    @eccsubs2179 Před 2 lety

    this is cool but i feel like im not learning anything, like when you write (new vector2) i want to know exactly what it does. I had to look up the difference between GetAxis and GetAxisRaw because you didnt explain it. I just wish you would explain, so this doesnt become like school where you learn all these topics and these strings of information but not the individual information themselves

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety +1

      6 hours ago I noticed you left a comment as well… You had an issue and hinted at me being the problem. Even when you later found out it was you who made an error.
      You have to be careful not to get too dependent on your tutor doing all the work for you. Even teachers at the University, are just meant to be there to guide you, and not show you every little micro fraction. I explain at least 95% of what I do on screen, which is plenty to guide you in the right direction.
      When you say “I had to look up”, it makes me think you aren’t aware that you are SUPPOSED to do that hehe. EVERYONE who does game dev, have to look up things 24/7. Even game devs who has been doing it for 20 years. 🙂 I am here to guide you, not hold your hands and do everything for you.
      I don’t know if it is unintentional, but your messages give off a very ungrateful vibe. When I wake up in the morning seeing multiple comments after another from the same person, and they all hint at that person having issues with my teaching, it sets a negative tone. Especially considering I do this for free.
      I get that it can be frustrating learning Unity, but you really should get in the habit of asking politely whenever you encounter any questions, instead of blaming me because my tutorial left you with questions afterwards. 🙂 I would hate for it to end up with me thinking “not this guy again” whenever I see your comments pop up in my notifications.

    • @eccsubs2179
      @eccsubs2179 Před 2 lety

      @@Dani_Krossing i am so sorry i was in a horrible mood and i kept getting frustrated. i didnt mean what i said and I understand, I wasnt trying to be ungrateful or anything I just wasnt in the mood. Im sorry for doing that, I had no reason to comment.

    • @eccsubs2179
      @eccsubs2179 Před 2 lety

      The tutorial did help, I managed to make a vertical movement system as well, (with a few strange bugs), I was just in a bad mood because I felt like I couldnt ever stay dedicated to a hobby or study or whatever so i blamed you. I hope you can understand

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      @@eccsubs2179 It's all good. 🙂 I'm glad you got things working.

    • @eccsubs2179
      @eccsubs2179 Před 2 lety

      @@Dani_Krossingthanks

  • @billielynploof9317
    @billielynploof9317 Před rokem

    Hello thank you for making these. I'm wishing for some help with something if you have time to volunteer your assistance. I am able to write these scripts and follow along. They do connect between unity and visual studio. However the namespace: using UnityEngine; : does not highlight and all the class items from the unity engine do not import into the visual studio program. As a result things like Rigidbody2D do not highlight and the tooltips do not appear when matches are made in your video they do not appear in visual studio because something is not connecting. The scripts work in unity though. Do you know how to correct this issue? Thank you.

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      Did you follow the installation video that I recommended watching in the previous video? The one that I linked in the description?
      In that one I show how to make VS work with Unity.
      If that doesn’t fix it, make sure you have the proper namespaces and libraries installed. You can add them through one of the menu items at the top of VS (I don’t remember the name on top of my head).

  • @jaydoesthat
    @jaydoesthat Před rokem

    I click on the scrip then it asks me to download an app. What do I do?

    • @jaydoesthat
      @jaydoesthat Před rokem

      Nevermind i just had to reinstall the 17 GB text editor. Why do I need so much space for this? Isn’t it just a “fancy text editor?”

  • @jaizz4495
    @jaizz4495 Před měsícem

    is this code good.. btw it's working for me -
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Test : MonoBehaviour
    {
    Rigidbody2D _rb;
    float _walkSpeed;
    float _inputHorizontal;
    // Start is called before the first frame update
    void Start()
    {
    _rb = gameObject.GetComponent();
    _walkSpeed = 5.5f;
    }
    // Update is called once per frame
    void Update()
    {
    _inputHorizontal = Input.GetAxisRaw("Horizontal");
    if (_inputHorizontal != 0) {
    _rb.AddForce(new Vector2(_inputHorizontal * _walkSpeed, 0f));
    }
    }
    }

  • @ph0xnix373
    @ph0xnix373 Před 2 lety

    When I created the script your using, AddForce caused my sprite to accelerate in a direction slowly rather than move as a player would. Not sure what I did wrong

    • @zyzz5070
      @zyzz5070 Před rokem

      Same brother, have you found why ?

  • @diablotempest103
    @diablotempest103 Před 2 lety

    now i got an error Assets/Scripts/Test.cs (25,26) error CS1026:) expected and Assets/Scripts/Test.cs (25,26) error CS1002: ; expected. What does this mean

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      It means you made a typo before that line.

    • @diablotempest103
      @diablotempest103 Před 2 lety

      @@Dani_Krossing ok thank you but does the file type matter, for example does it have to be assembly-c# or can it be something like miscellaneous

  • @rustygamer9416
    @rustygamer9416 Před 2 lety

    I love you Dani.

  • @itsnomis2410
    @itsnomis2410 Před rokem

    i have tried like 7 other unity tutorials and no one works. not trying to be rude but your script somehow dosnt work even though i copied everything you did. im a complete beginer, the error says: Assets\scripts\Test.cs(27,29): error CS1003: Syntax error, ',' expected
    no idea what it means

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      It means you made a typo, and that your code is expecting a coma around line 27-29 in that script. 🙂 The code will still work if typed correctly, so always make sure you type everything correctly.
      I know you say "i copied everything you did", but I promise that most people believe that when they get errors, until they find out that they missed something.

  • @kazkat7368
    @kazkat7368 Před rokem

    hi when i enter the code exactly what u did but my object isnt moving at all :( what em i missing ??

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      If you paste your code in here, I can help you figure it out 🙂 99% of the time it is because of a typo/error.

    • @kazkat7368
      @kazkat7368 Před rokem

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class TEST : MonoBehaviour
      {
      Rigidbody2D _rb;
      float _walkSpeed;
      float _inputHorizontal;
      // Start is called before the first frame update
      void Start()
      {
      _rb = gameObject.GetComponent();
      _walkSpeed = 5.5f;
      }
      // Update is called once per frame
      void Update()
      {
      _inputHorizontal = Input.GetAxisRaw("Horizontal");
      if (_inputHorizontal !=0)
      {
      _rb.AddForce(new Vector2(_inputHorizontal*_walkSpeed,0f));
      }
      }
      }

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      ​@@kazkat7368 Ah, I see the problem. You need to make sure that you include spaces in your code, just like I did in the video.
      These are the lines I could see you omitted the spaces:
      if (_inputHorizontal !=0)
      Should be:
      if (_inputHorizontal != 0)
      And
      _rb.AddForce(new Vector2(_inputHorizontal*_walkSpeed,0f));
      Should be:
      _rb.AddForce(new Vector2(_inputHorizontal * _walkSpeed, 0f));

  • @dragonstone8201
    @dragonstone8201 Před 2 lety

    my script editor is notepad not visual studio how do i change this?

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      In the first lesson I mentioned that I had a video on how to change your script editor. 🙂 It's linked in the description of lesson #1.

    • @dragonstone8201
      @dragonstone8201 Před 2 lety

      @@Dani_Krossing Thanks!

  • @realworldcodingapplications

    when you open the project, which kind of project did you open? I followed exact same script but for some reason it doesnt work, lots of errors

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      Which errors do you receive?

    • @korragnarok1536
      @korragnarok1536 Před 2 lety

      @@Dani_Krossing I'm not receiving any errors but it's still not doing anything when I click the arrows. 🤦‍♀ I don’t know if i have a typo or what, but I keep rechecking the script and it's the same as yours. Ahhhh😣

    • @jacobh1833
      @jacobh1833 Před 2 lety

      @@korragnarok1536 I had a different file name and class name (test vs Test), that might be the issue.

  • @maxs3918
    @maxs3918 Před rokem

    Hi! I'm having a bit of issue with my code. I'll post it in the comment below, but I'm getting the errors "Assets/Scenes/Scripts/test.cs(24,12): error CS8598: The suppression operator is not allowed in this context" and "Assets/Scenes/Scripts/test.cs(24,12): error CS0029: Cannot implicitly convert type 'float' to 'bool'"

    • @maxs3918
      @maxs3918 Před rokem

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Test : MonoBehaviour
      {
      Rigidbody2D _rb;
      float _walkSpeed;
      float _inputHorizontal;
      // Start is called before the first frame update
      void Start()
      {
      _rb = gameObject.GetComponent();
      _walkSpeed = 5.5f;
      }
      // Update is called once per frame
      void Update()
      {
      _inputHorizontal = Input.GetAxisRaw("Horizontal");
      if(_inputHorizontal ! = 0)
      {
      _rb.AddForce(new Vector2(_inputHorizontal * _walkSpeed, 0f));
      }
      }
      }

    • @Dani_Krossing
      @Dani_Krossing  Před rokem +1

      Your last if statement has a extra space. It should be “!=“ and not “! =“ 🙂

    • @maxs3918
      @maxs3918 Před rokem

      @@Dani_Krossing Thank you so much! You're the best!

  • @perezrodriques5268
    @perezrodriques5268 Před 2 lety

    I've checked everything but I still have an error saying
    Assets\script\test.cs(25,13): error CS0029: Cannot implicitly convert type 'float' to 'bool'

    • @perezrodriques5268
      @perezrodriques5268 Před 2 lety

      and my rigidbody2d and input are changing colour

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      Can you paste in your code here? It says you made a typo, and are comparing a bool and a float.

  • @lainhayden4749
    @lainhayden4749 Před 2 lety

    the example script isn't working for me and I'm confident i did it right, a lot of things aren't changing colors for me like yours and it isn't bringing up the options for things like Input or AddForce

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      Seems like your Intellisense isn't enabled. In the description of the last lesson, I have a "how to install Unity" video linked, which shows how to set up Intellisense. 🙂

    • @lainhayden4749
      @lainhayden4749 Před 2 lety

      @@Dani_Krossing I fixed the problem thank you!

    • @perezrodriques5268
      @perezrodriques5268 Před 2 lety

      @@lainhayden4749 how did you fix it

    • @jacobh1833
      @jacobh1833 Před 2 lety

      @@perezrodriques5268 edit->preferences, under Analysis in the left window, find 'External tools', and choose Microsoft visual Studio (2022 in my case) as your editor. Then check off each box for 'Generate .csproj files for:'. Then you should be able to see the classes/function methods get recognized. Hope this helps!

  • @Simo-cy6kv
    @Simo-cy6kv Před 2 lety

    My Code isnt working even though I did the exect same things you did, my MonoBehaviour is not coloured green and the other commands in the program are not coloured as well. Dont know what to do about it!

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety +1

      I can with 99% certainty guarantee you that it is not working because you either made a typo, or an error along the way. 🙂 So far every time people tell me they "did the exact same things I did", it turned out they hadn't.
      But to narrow things down for you...
      Firstly, the reason your colors aren't changing in Visual Studio, is because you haven't set it up yet. This video here shows how to do it: czcams.com/video/ewiw2tcfen8/video.html&ab_channel=DaniKrossing
      Secondly, you should have received an error in your Console to help narrow down the issue. "My Code isn't working" doesn't give us a lot to work with. 🙂 If you receive no error in the console, it is most likely an error you made in Unity, and not the code. For example forgetting to apply the script to the gameobject, etc...

    • @Simo-cy6kv
      @Simo-cy6kv Před 2 lety

      @@Dani_Krossing I forgot to connect my unity with VS.
      Thank u very much for your help and especially the quick answer! :)
      Your Videos are helping me a lot so keep going!!!

  • @Orse666
    @Orse666 Před rokem

    does he have another video just on VS? he did some stuff there that I couldn't work out like when he spaced down to write a new script and "{" these characters auto filled underneath for his next script yet I couldn't work out how he did it. I followed everything exactly how he showed and watched the other videos to make sure it was setup correctly but once doing the script (and I mean EXACTLY how it looks on his screen), it popped up with 11 errors. I assume I'm using VS incorrectly.

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      I can’t quite follow your comment? Which part specifically confused you?

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      In the first lesson I did mention that I had another “how to install Unity” video linked in the description. Did you make sure to watch that one first? It also shows how to set up VS.

    • @Orse666
      @Orse666 Před rokem

      @@Dani_Krossing Hey Dani, I had a friend go over everything with me, turns out Unity was using the New "input system package", I just had to change it to the old "input manager" and everything worked!
      Great video's by the way. You explain things really good so an idiot like me to understand! I'll be watching all of your lessons!

    • @ShepherdQ921
      @ShepherdQ921 Před rokem

      @@Orse666 how did you do that?

  • @saroman9370
    @saroman9370 Před 2 lety

    I cant move my player all tho i coded c#

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety +1

      I can with a 99% certainty guarantee you that you made a typo in the code, or you forgot something in the Unity editor, like for example adding the script to the player. 🙂

  • @ShepherdQ921
    @ShepherdQ921 Před rokem

    my code is telling that the horizontal axis is not set up even tho i followed the instructions the error gave me and nothing happened

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      If you paste the code here, and can tell you what typo is there 🙂

    • @ShepherdQ921
      @ShepherdQ921 Před rokem

      @@Dani_Krossing
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Test : MonoBehaviour
      {
      Rigidbody2D _rb;
      float _walkspeed;
      float _inputHorizontal;
      // Start is called before the first frame update
      void Start()
      {
      _rb = gameObject.AddComponent();
      _walkspeed = 5.5f;
      }
      // Update is called once per frame
      void Update()
      {
      _inputHorizontal = Input.GetAxisRaw("horizontal");
      if (_inputHorizontal != 0)
      {
      _rb.AddForce(new Vector2(_inputHorizontal * _walkspeed, 0f));

      }
      }
      }

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      You misspelled “Horizontal” inside the input. It needs to be capitalised.

    • @ShepherdQ921
      @ShepherdQ921 Před rokem

      @@Dani_Krossing wait hold on now im getting another error object reference not set to an instance of an object

    • @ShepherdQ921
      @ShepherdQ921 Před rokem

      @@Dani_Krossing i figured it out on my own! i had accidentally put "AddComponent" on line 14 instead of "GetComponent"
      thanks for all the help😃

  • @BboyofRandomness
    @BboyofRandomness Před rokem

    Hello I've spent the past 40 minutes double and triple checking everything for my code but the character simply wont move. I dont know what Ive done wrong but I can't find any difference in the code. No errors are popping up, the character simply doesnt move. Ill attach my code in this comment. Thank you for these tutorials super informative and helpful

    • @BboyofRandomness
      @BboyofRandomness Před rokem

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Test : MonoBehaviour
      {
      Rigidbody2D _rb;
      float _walkSpeed;
      float _inputHorizontal;
      // Start is called before the first frame update
      void Start()
      {
      _rb = gameObject.GetComponent();
      _walkSpeed = 5.5f;

      }
      // Update is called once per frame
      void Update()
      {
      _inputHorizontal = Input.GetAxisRaw("Horizontal");
      if (_inputHorizontal != 0)
      {
      _rb.AddForce(new Vector2(_inputHorizontal * _walkSpeed, 0f));
      }
      }
      }

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      Having looked over your code twice, I can't see any errors either, so the error has to be in the Unity Inspector. 🙂
      Did you double check that:
      - Your player has a RigidBody2D attached?
      - That you used the RigidBody2D and not RigidBody?
      - That you added your script to your player?
      - That you didn't forget to save your script?

    • @BboyofRandomness
      @BboyofRandomness Před rokem

      Hi again I've somehow fixed it! I attached the script to the sprite multiple times but for some reason it kept removing itself(?)! After reattaching the script for the 4th time it works!! So happy to see it move lol

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      I should mention that the example in my video, has a few things "not to do", such as not using Time.deltaTime in Update(), or splitting the physics movement into another method called FixedUpdate(). So if you are 100% sure there are no errors, these could be the last reason for why it's not working. 🙂

    • @BboyofRandomness
      @BboyofRandomness Před rokem

      @@Dani_Krossing thank you very much for your reply! (So incredibly fast too) Seemed to be linked to being unlinked to the object x) ok onto the next videos!

  • @KillAllCommies2
    @KillAllCommies2 Před 28 dny

    Compile error: the referenced script (unknown) on this behaviour is missing

  • @Jooby_On_Rust
    @Jooby_On_Rust Před 2 lety

    hey im really new to making games but heres my problem
    Assets\scripts\Test.cs(27,38): error CS0103: The name '_imputHorizontal' does not exist in the current context
    so it wont let me play the game and ive been trying to fix this but nothings worked please help and thanks

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety +1

      I'm going to give you a hint 😉 See if you can spot the mistake...
      Hint:
      _imputHorizontal

    • @Jooby_On_Rust
      @Jooby_On_Rust Před 2 lety +2

      @@Dani_Krossing im so dumb thank you for the help

    • @Jooby_On_Rust
      @Jooby_On_Rust Před 2 lety +1

      @@Dani_Krossing i looked over it and it says inputHorizontal on all of them i cant seem to find imputHorizontal

    • @Jooby_On_Rust
      @Jooby_On_Rust Před 2 lety +2

      nvm got it thanks for the help

  • @DannyBoy443
    @DannyBoy443 Před rokem

    Elon Musk has a Unity side hustle. lol

  • @cosminpirlog7170
    @cosminpirlog7170 Před rokem

    idk man why i tried to do the same code and it told me i have errors

    • @Dani_Krossing
      @Dani_Krossing  Před rokem

      If you share the errors I can tell you what is wrong 🙂 I can guarentee that in 99% of cases when people "copied my code exactly", it turned out they didn't.

    • @cosminpirlog7170
      @cosminpirlog7170 Před rokem

      @@Dani_Krossing sorry man i fixed my problem i didnt pay attention to gravity so i had it on 5 it works sorry for the disturbance

  • @leolehane9988
    @leolehane9988 Před 2 lety

    this is basically like javascript. the only reason I understand the code is because I am also studying arduino and python.

    • @Dani_Krossing
      @Dani_Krossing  Před 2 lety

      Yeah at some point after learning many different languages, you kind of start noticing the similarities between them all. 🙂

  • @BlackDev
    @BlackDev Před 2 lety

    5:40 one week two 7+ hour course c# vids it'll be like English

    • @BlackDev
      @BlackDev Před 2 lety

      correction just watch his videos this is amazing im coming from a 7hour c# vid and that teachers great, but this is another level.