Loops and Arrays | Unity C# Basics Part 2 | Unity Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ค. 2024
  • Learn about some critical fundamentals - Arrays and Loops. They usually go hand in hand so it just felt right to talk about them together. In this tutorial, aimed at absolute beginners who have very little to no coding experience whatsoever, you'll learn:
    ⚫ What Loops are.
    ⚫ What kinds of Loops are available in C#
    ⚫ A step-by-step breakdown of what each statement is doing, why it's happening, and how it works.
    ⚫ How to make multiple TextMeshProUGUI components on the screen count up over time from a single script
    💸 Ongoing sales 💸
    ⚫ See all active asset sales on the Asset Store: assetstore.unity.com/?on_sale...
    ⚫ Save 25% off your first Asset Store Order: prf.hn/click/camref:1101l9QvC...
    ⚫ Save up to 50% on NEW Assets: assetstore.unity.com/?new_sal...
    👨‍💻As always, all code from this video is available on GitHub: github.com/llamacademy/unity-...
    ❤ Believe in LlamAcademy's mission and have received value from the videos? Become a Patreon Supporter or TH-cam Member:
    ⚫ Patreon: / llamacademy
    ⚫ TH-cam Member: / @llamacademy or click the Join button on any video
    Full Series Playlist Here: • Want to Start Writing ...
    ⚫ Part 1 - Writing your first script - • Want to Start Writing ...
    ⚫ Part 2 - Loops and Arrays - • Loops and Arrays | Uni...
    ⚫ Part 3 - Unity Component Lifecycle - • MonoBehaviour Lifecycl...
    ⚫ Part 4 - Static vs Instances - • Static vs Instances | ...
    ⚫ Part 5 - Delegates - • Delegates? Basically, ...
    ⚫ Part 6 - Inheritance & Interfaces - • Inheritance and Interf...
    ⚫ Part 7 - Compositional Relationships - • Compositional Relation...
    📝📝📝YOUR HOMEWORK!📝📝📝
    Tip: There's a bunch of ways to approach this, but one way that I like to do it takes advantage of a handy "remainder" operator called the modulus operator: docs.microsoft.com/en-us/dotn...
    Update this script so will display the updated TimeDisplay on only a single TextMeshProUGUI component on a frame.
    On frame 1, the first TextMeshProUGUI component should display the TimeDisplay
    On frame 2, the second TextMeshProUGUI component should display the updated TimeDisplay, the first TextMeshProUGUI component should still show the last TimeDisplay value.
    On frame 3, the third TextMeshProUGUI component should display the updated TimeDisplay, the first TextMeshProUGUI component should still show the first TimeDisplay value, and the second TextMeshProUGUI component should display the last value.
    etc... through the end of the TextMeshProUGUI components. Once we've reached frame 8 (since we only have 7 TextMeshProUGUI components) it should update the first TextMeshProUGUI component again and continue with this pattern.
    This should work for any number of TextMeshProUGUI components, or any size of the Texts array.
    Add a comment below with a video showing your code and the end result.
    📚 For those looking to get ahead of the next video, consider some further reading on resources I brought up during this tutorial 📚
    ⚫ docs.microsoft.com/en-us/dotn...
    ⚫ docs.microsoft.com/en-us/dotn...
    ⚫ en.wikipedia.org/wiki/For_loop
    ⚫ en.wikipedia.org/wiki/While_loop
    ⚫ en.wikipedia.org/wiki/Do_whil...
    ⚫ en.wikipedia.org/wiki/Foreach...
    ----
    Most tutorials come from knowledge gained making survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.
    I also have some Unity Assets (affiliate link): assetstore.unity.com/publishe...
    Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
    #unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment
    Chapters:
    00:00 What to Expect
    02:45 Review Scene
    03:33 Array Introduction
    06:50 The FOR Loop
    11:33 Demo
    12:40 The WHILE Loop
    15:57 The DO WHILE Loop
    18:32 The FOREACH Loop
    20:06 Array Creation and Assignment
    22:22 Homework, Last Homework Answer, and Final Thoughts

ความคิดเห็น • 16

  • @MM-bw1lo
    @MM-bw1lo 6 หลายเดือนก่อน +2

    I've struggled for a year now, your videos are the only things that have truly helped me to learn... thanks so much for this content.

  • @Ma_cieK
    @Ma_cieK 2 ปีที่แล้ว +4

    You have a great way of explaining stuff. I really enjoyed the video. I hope you will continue with the series. Thank you!

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว +1

      Many more episodes in the works!

    • @Ma_cieK
      @Ma_cieK 2 ปีที่แล้ว

      @@LlamAcademy awsome!

  • @a.technology1446
    @a.technology1446 2 ปีที่แล้ว +1

    Thanks for your efforts, we are really appreciated. Can u explain later on how to make enemies flying after get punched? With and without ragdoll??

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว +1

      Thank you! I have something like that on the topic list. I’ll see if I can do that soon

  • @jellybeann69420
    @jellybeann69420 2 ปีที่แล้ว +3

    Hii!, For loops are a little hard. I dont really understand them but lets hope after this video i do!

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว

      I hope they make sense now!

  • @jlonginotti1
    @jlonginotti1 2 ปีที่แล้ว +2

    I noticed in your first video to this one you've changed the SetText portion of your code to include $"{TimeDisplay... Why is that?

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว

      Great catch! I didn't mean to change that. You can retain the previous code, or keep this, it's functionally the same as what it was before (if anything what I have here is less performant 😳)! Sorry for the confusion!

  • @ronigleydsonvilasnovas8067
    @ronigleydsonvilasnovas8067 2 ปีที่แล้ว +2

    these things gave me nightmares a while ago 😅

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว +2

      😁they're usually scary topics the first go-around, especially if they're teaching you with pointers!

  • @obsoletevalues6209
    @obsoletevalues6209 4 หลายเดือนก่อน

    Did you provide the solution anywhere to the homework assignment at the end of Part 1?

    • @LlamAcademy
      @LlamAcademy  4 หลายเดือนก่อน

      Yup! Around 23:17

  • @xKeray
    @xKeray 2 ปีที่แล้ว

    unity sucks

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว +3

      No need to click on videos about unity tutorials then 🙂