Godot Beginner Tutorial 12: Singleton

Поділитися
Вставка
  • Опубліковано 28 чер 2024
  • Throughout the Godot Beginner Tutorial series, we will be covering the bare essentials to building a game in Godot. In a beginner friendly manner, with the free game engine Godot, each tutorial will be a stepping stone towards completing your first game.
    Through the series, we will cover the 2d side of the engine, including: sprites, scripting, UI (very basic), parallax, and multiple levels!
    #GodotEngine
    Continuing the beginner-friendly top-down shooter series, we are going to fix a glaring issue in our code by giving all our scripts access to our Player through the Singleton pattern.

КОМЕНТАРІ • 30

  • @johnnewton7401
    @johnnewton7401 4 роки тому +14

    This video singehandedly cleared up so many things about Godot for me. I felt like I really hit a wall in learning the godot structure but this helped immensely. Thanks!! I will definitely be watching for more!

  • @Kojow7
    @Kojow7 3 роки тому +10

    @2:46 This guy's trying too hard to convince us he's a human. Makes you wonder. :)

  • @Lligamuue
    @Lligamuue 4 роки тому +3

    You are a great teacher. As an artist discovering game programming everything you show makes sense. You are very concise and the pace is just right. I already have a scientific background so I guess it might help. Thank you.

  • @marioroberti
    @marioroberti 2 роки тому +1

    This is fan-effing-tastic!!!! Thank you THANK YOU!!! Singletons as shown by you allowed me to get over the hurdle of not having global variables from the get-go. Awesome. Thank!!!

  • @user-zp9cm4by4d
    @user-zp9cm4by4d 2 роки тому

    Thanks man, it's short and clear explanation, it helpe so much

  • @faefiction4501
    @faefiction4501 2 роки тому

    absolute amazing! def checking out more

  • @DrWho2008t101
    @DrWho2008t101 3 роки тому

    you are one of the best teachers around teaching godot. make more if you feel like it and motivated.

  • @Capn-Coin
    @Capn-Coin 3 роки тому

    Thank you sooo much!! Ive been struggling with this all day and after watching your 6min video it all makes sense.

  • @AdventurersTavern
    @AdventurersTavern 4 роки тому

    it’s short and to the point. love it.

  • @CorvusNumber6
    @CorvusNumber6 4 роки тому

    Thank you! This was explained brilliantly! Liked and subbed!

  • @kizz06
    @kizz06 3 роки тому

    Brilliant tutorial! Subscribed!

  • @aleksandersanya1817
    @aleksandersanya1817 Рік тому

    Very useful, thanks!

  • @Gphdwre
    @Gphdwre 3 роки тому

    You are producing good content and I hope your videos become more popular and more views and likes.

  • @c1m50c
    @c1m50c 4 роки тому +2

    Thank you for this tutorial dog, helped a lot :)

    • @AlvinRoe
      @AlvinRoe  4 роки тому

      Thanks friend! I'm glad you enjoyed it. Thanks for leaving a comment. It really keeps the motor running.

  • @crimson8558
    @crimson8558 4 роки тому +1

    I love the little bit of fun, which keeps me smiley faced all the time...
    Also in the previous episode... Love ur vids, Thanks a lot

    • @AlvinRoe
      @AlvinRoe  4 роки тому +1

      I'm glad it comes across. I try to have fun with it, so that it's not boring to watch. Thanks for the comment, friend!

  • @heckyes
    @heckyes 3 роки тому

    Awesome.

  • @akashkheroniya4782
    @akashkheroniya4782 2 роки тому

    you are genius

  • @cgworkest
    @cgworkest 4 дні тому

    Глобальная проблема работы с Godot + Singlton через plugins SQLite не могу подключить singlton чтобы при входе в своего пользователя мог попасть в своё и только своё user game window и работать дальше с ним по типу параметризации данных и прочего по типу games.

  • @pixelrabbit261
    @pixelrabbit261 4 роки тому

    Nice

  • @EnormiE
    @EnormiE Рік тому +1

    Now after making singleton thing in project settings nodes name is automatically uppercsae, so now you will reffer to this as Global.player, not global.player

    • @juanpena808
      @juanpena808 Рік тому

      Hey, thank you for that bit of information! I was getting a debbuger error because of that, but I didn't know; I just went back to the Autoloader, changed the first letter of the singleton to lowercase, and that did it!
      But I do have a follow-up question that perhaps you might answer: after I did that, I played the scene and everything was OK, but then I realized that I had left the player node in 0 position within the scene tree. So I moved it to another position just to try it out, and then when I played the scene it immediately crashed, which is weird because due to the "global.player = self", the enemy targeting shouldn't be position-dependant anymore. Any ideas on what could it be ('cause I'm a noob on this whole thing haha)?

  • @ezion67
    @ezion67 3 роки тому

    Good tutorial. The use of singletons seems to get a bit of hate by some devs. Maybe you could explain a bit about the risk of name-collisions when using globals and how to avoid problems by using properly name-spaced (uniquely named) variable and function names?

  • @jamesxxxyz8775
    @jamesxxxyz8775 4 роки тому +1

    When i use " player = Global.player" instead of "player = get_parent().get_child(0)" i get an error in this line "var ret = (target.position-position)" > Invalid get index "position" (on base:"NIL")

    • @Selmeras15
      @Selmeras15 2 роки тому

      Hey James. I have the same issue. Did you managed to fix it?

    • @michaellambert5614
      @michaellambert5614 Рік тому

      I, too, have this problem.

    • @michaellambert5614
      @michaellambert5614 Рік тому +1

      @@Selmeras15 Good news. I figured it out. If you declared the player as a separate variable in the enemy's code (var player = global.player instead of player = global player) then you will get an error. This is because player was already declared with var beforehand. You also need to make sure that you are loading up the main scene instead of just the enemy's scene. If you load the enemy's scene separately, the enemy script won't have access to the player script.

    • @Selmeras15
      @Selmeras15 Рік тому +1

      @@michaellambert5614 Thanks so much for answering. You rock!