Godot 4 Crash Course #4 - Adding Meteors

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 62

  • @madsoncaminha2517
    @madsoncaminha2517 10 місяців тому +9

    Your vids are amazing, right amount of info, the exercises are challenging but not out of the context you're teaching, really good stuff, congrats

    • @NetNinja
      @NetNinja  10 місяців тому +3

      I really appreciate that! :) thanks for watching

  • @soumyameta
    @soumyameta 4 місяці тому +16

    Please pin this fix,
    Those who having problem that the meteors isn't spawning, just toggle/on the auto start in the timer inspector, that's it you are good to go.
    Love from India.

  • @daireks
    @daireks 7 місяців тому +6

    these are really great tutorials/introduction to the engine! thank you!!!

    • @NetNinja
      @NetNinja  7 місяців тому

      Awesome, thanks! :)

  • @NoraNoita
    @NoraNoita 7 місяців тому +2

    I was struggling a lot on the 10:50 exercise, for the speed I figured that one out rather easily, although I executed it slightly different, the big first hurdle was the rotation, which I used rotate(-0.2, 0.2) for, which worked I guess, but to find that took a really long time and none of the other methods I tried worked.
    Then finding a way to set the angle of the meteors had me completely stumped, I tried looking for something similar to rotate, but nothing worked, I would've never guessed to set the x value on the Vector2 there.
    Same for the image one, I knew how I would want to do both of these logically, but not finding the correct code to do it was really frustrating.

  • @slosh7072
    @slosh7072 Місяць тому +1

    For randomising the texture, I didn't use the concatenation trick you did. Instead, I loaded the 5 sprites into variables, put them each into a list and had _ready() choose a random index from that list. I considered your method, but the docs for the load() method seem to suggest that it's preferable to call it as few times as possible, e.g. not in _ready() or _process().

  • @Outlines
    @Outlines 11 місяців тому +2

    i will not shave until netninja uploads an updated flutter tutorial

    • @NetNinja
      @NetNinja  11 місяців тому +1

      Currently working on it :)

  • @dabbabimarwen7474
    @dabbabimarwen7474 4 місяці тому +2

    Good teacher : print and test every step !!! ♥

  • @kingofnothing2260
    @kingofnothing2260 6 місяців тому +2

    Ty so much for the beginner and intermediate help. You are teaching me so much

  • @coprinosis
    @coprinosis 2 місяці тому

    This one was a great challenge, but I did misinterpret one part of the exercise, randomizing the meteor direction. Without continuing the video, I figured out how to get meteors travelling through the scene from every direction, not just from the top down. Which was awesome, but when I continued the video, it became apparent that I over-complicated it a little.
    Then trying to get the rotation working helped me learn about how each meteor is updated. Evolving from meteors that have their vectors updating constantly, looking like meteor microbes spreading across the screen is some strange unison, to working as intended. A really neat way to learn, and it reminds me of how much I really enjoy problem-solving.
    I only have one question regarding 'CollisionShape2D'. I ended up finding a way, after prompting 'ChatGPT' a few times, and troubleshooting, to get the collision shape updating to a 'CircleShape2D' given the greatest (x, y) value of the imported texture. It was a neat thing to learn, but did I miss something in the video in regard to the collision shape size, or do all the meteors, regardless of size, share the same 'CollisionShape2D' in this video? Is this something discussed in a later video?
    I am moving quite slowly through the tutorials to squeeze the most out of the rabbit holes I am finding myself in, so I apologize if this is answered later on. Thought I would share my learning experience, and mention how much I am enjoying the experience so far.
    Cheers

  • @MrTact67
    @MrTact67 5 місяців тому +4

    You should create your RNG as a property of the meteor script, rather than recreating a new one every time you spawn in a new meteor.

  • @cyrlaineaparecidacasagrand2010
    @cyrlaineaparecidacasagrand2010 5 місяців тому

    For the graphic I had created a huge if statment but this path solution is much better! Thanks for the great tutorials!

  • @beardalaxy
    @beardalaxy 6 місяців тому

    Was totally stumped on the random texture exercise lol. I got the rotation, speed, and direction right but I put the variables for them underneath the process function instead and that was causing them to always go to the max value, even though I was printing the values beforehand and it seemed like they were random. So, I'm not sure exactly what went wrong there, but now I know that I should definitely be setting variables for that sort of thing outside of the process function and then actually using them in the process function. I didn't know you could overwrite variables from other parts of the script (and I'm coming from an engine where all variables are global so it's a bit of an adjustment).

  • @barsztik
    @barsztik 26 днів тому

    14:00 I wrote:
    direction_x = randf_range(-1, 1)
    instead
    direction_x = rng.randf_range(-1, 1)
    Its also works, but Godot colored "randf_range" on violet instead of blue
    What is the diferent?

  • @kiyoutakaayanokouji3701
    @kiyoutakaayanokouji3701 6 місяців тому +1

    bro where did you got that signals i couldn't find it

  • @bassseeker91
    @bassseeker91 4 місяці тому +2

    Hello. I am following your tutorial closely. I have a problem, meteors do not fall from the beginning of the x axis, i.e. from 0, but from half the screen. I used print to check if the random number generator does not generate small numbers, but everything is fine. I made a fullscreen and then I saw that large values ​​fall outside the game screen. Do you have any idea what is causing this? I have the screen set to 1280 x 720

    • @bassseeker91
      @bassseeker91 4 місяці тому

      I set randi range (-1000, width) and now meteors are falling from the begining of the screen. Just game is counting X = 0 as middle of the screen.

    • @ChrisTilleyCA
      @ChrisTilleyCA 4 місяці тому +3

      I had the same problem and it appears that my meteor scene had the meteor at some offset. I went in to the meteor scene and set its position to 0,0 and that seems to have fixed my problem. I also had to change the CollisionShape2d to 0,0. I am curious if it works for you

    • @mostlybikes7842
      @mostlybikes7842 5 днів тому +1

      @@ChrisTilleyCA I was puzzled over this one. Thanks for the solution

  • @braunii0
    @braunii0 8 днів тому

    To get a random image i used an array to store each image and generated a random index from 0 to len(arr) - 1

  • @legosteam4693
    @legosteam4693 3 місяці тому +2

    I'm in Godot 4.3
    When I use your rotation code for the meteors, it seems as if it's rotating the whole meteor scene because my meteors start turning and curving rather than traveling straight with rotation.
    I fixed this in my code by adding $Sprite2d.rotation_degrees += MeteorRotationSpeed * delta.
    $Sprite2D refers to the Sprite2D node in the meteor scene. This will rotate the sprite itself rather than the entire meteor scene so that it doesn't change directions midflight.

    • @kishanthakar8715
      @kishanthakar8715 2 місяці тому

      Thanks so much I was wondering why that was happening

    • @christopherrogers532
      @christopherrogers532 2 місяці тому

      That said it is funny as heck and has it's uses.

  • @molnarvgc4976
    @molnarvgc4976 Місяць тому

    My meteors aren't rotating independently, they slowly rotate and the trajectory it is following changes to whatever it is pointing at.
    Causes meteors to swirl around the screen really fast.

  • @ReverendLevi
    @ReverendLevi 4 місяці тому

    I have a question concerning the meteor rotation. When the lines for rotation are active, my meteors not only rotate at varied speeds, but they also turn towards the rotation. With the rotation lines removed, the meteors function correctly aside from not rotating. When the rotation speed is raised to a point, the faster meteors will travel onto the screen, then fly in circles. Where should I look for documentation as to what I've done incorrectly?
    Also, thank you very much for sharing your knowledge!

  • @charliecharliewhiskey9403
    @charliecharliewhiskey9403 5 місяців тому

    I didn't have the assets pack, so for me I had different size meteors. So I instead had an array of loaded packed scenes (each meteor type being a scene) which I then randomly selected to instantiate.

  • @TwoPluzzTwo
    @TwoPluzzTwo Місяць тому

    I suck at this, I am getting an error at 18:24 despite following your instructions.
    Only difference is I made my own textures since I can't find your file containing them. They are still .png files however.
    Here is the error:
    Invalid assignment of property or key 'texture' with value of type 'CompressedTexture2D' on a base object of type 'null instance'.
    I don't know what I done wrong, I checked, I don't have any CompressedTexture2D's?
    Please help...

  • @baYnetwaYne
    @baYnetwaYne Місяць тому

    Have a problem with the randomization of the meteors...when i remove (the randomization steps they appear) but when i put them in the code...i just have the player

  • @RoninSamurai
    @RoninSamurai 3 місяці тому +1

    at 18:06 when I add the path, it isn't spawning anything (yes I have the timer on auto start), not sure why it's doing that, as I've done everything the same way...

    • @Elena-ed8eo
      @Elena-ed8eo 2 місяці тому +1

      I'm having the exact same issue😭 I'll update if I figure it out

    • @KyTheCrusader
      @KyTheCrusader Місяць тому +1

      @@Elena-ed8eo Im having the same issue that both of you are. Where you guys able to find a fix?

    • @RoninSamurai
      @RoninSamurai Місяць тому

      ​@@KyTheCrusader Nope, I just left it how it was tbh, I tried researching but couldn't find out why, I even tried renaming the files to what he had and still didn't work... I ended up stopping after that, and moved on to something else lol, I apologize for not finding the solution though!

    • @KyTheCrusader
      @KyTheCrusader Місяць тому

      @@RoninSamurai No worries! Thanks for filling me in though!

  • @gbilo24
    @gbilo24 2 місяці тому

    Thanks a lot for these great tutorials!!!

    • @NetNinja
      @NetNinja  Місяць тому

      That means a lot :) thanks William

  • @jbaisden
    @jbaisden Місяць тому

    Great tutorial! The assets for the game include meteors of varying sizes, which would affect collision detection as the collision area of the big ones is...well bigger than the small. I'm curious: How can we handle this? It's obviously not truly needed here as there are varying meteors of the same size, but my brain is curious!

    • @mikelike16
      @mikelike16 Місяць тому +1

      if your still curious I wanted to implement the same thing and this is how I ended up doing it:
      under the ready func
      update_collision_shape($Sprite2D.texture)
      and this as a separate func:
      func update_collision_shape(texture):
      # get the dimensions of the texture
      var texture_size = texture.get_size()
      var shape = CircleShape2D.new()
      shape.radius = min(texture_size.x, texture_size.y) / 2
      $CollisionShape2D.shape = shape

  • @Boring_sandy
    @Boring_sandy 26 днів тому

    What if all graphics have different shapes i dont think only one collison shape 2d can work.
    Please tell me iam having this problem.

  • @tombkings6279
    @tombkings6279 9 місяців тому

    The method Instantiate for a packed scene What does it do? like does it loads meteor each time the timer finishes into the level scene?

  • @rafamiosek9448
    @rafamiosek9448 3 місяці тому

    I have errors doing the part with "var width = get_viewport..." in meteor script. Im following your steps 1:1 everything exactly the same

  • @bahram1010
    @bahram1010 11 місяців тому +2

    Thank you bro👍

    • @NetNinja
      @NetNinja  11 місяців тому +1

      No problem! 👍

  • @kingshahzad78
    @kingshahzad78 4 місяці тому

    Thank Dear.... Wonderful Explanation like always😄

  • @the_blue_hole
    @the_blue_hole 3 місяці тому

    Because of this part i had to redo everything 4 time because tscn one didn’t work
    Edit1: 6 times why it break bro am so tried i have been trying for 6 hours i did nothing wrong and it break
    Edit2: i just can’t get the meteor spawn/clone it self it doesn’t even show and i turned on autostart
    Edit3: now i can’t move
    Edit4: i got meteors to work the issue was the width in var random_x = rng.randi_range(0, width) break it so i changed it to 1280 but i can’t move my character any help?

  • @Im_a_Chill_Panda
    @Im_a_Chill_Panda 4 місяці тому

    The spawn point on my meteors seems to be moving down, the lasers are also only offset. Any idea what might be causing it?

    • @Im_a_Chill_Panda
      @Im_a_Chill_Panda 4 місяці тому

      I fixed the lasers, but the meteor spawn is still falling.

    • @gmailer59
      @gmailer59 4 місяці тому

      ​@@Im_a_Chill_PandaInsert the code

  • @kishanthakar8715
    @kishanthakar8715 2 місяці тому

    I know this sounds weird but my meteor statt spawning from the top but then they start spawning halfway down and finally they stop spawning and i am not sure why i have rng(-150,-50) even if i set 0 it still doesn't change

    • @kishanthakar8715
      @kishanthakar8715 2 місяці тому

      Never mind thanks to @legosteam comment he worked out that I need to $meteor as in 4.4 you move the entire scene if you don't add meteor

  • @Robonator14
    @Robonator14 10 місяців тому

    How do you add randomized scaling for meteors to this? I have tried it myself but i could not get it to not crash on me.

    • @ichizen910
      @ichizen910 5 місяців тому

      You would need to add the following to the script "var random_scale = rng.randf_range(0.25 , 2.00)" AND "scale = Vector2(random_scale, random_scale)" REMOVE THE QUOTATION MARKS

  • @ItzFantasy
    @ItzFantasy 11 місяців тому

    you are the guy from clear code right?

    • @devdeclan
      @devdeclan 11 місяців тому

      What's clear code? is that a channel, lol

  • @Spyderist
    @Spyderist 11 місяців тому

    great video

  • @AndreLaurin
    @AndreLaurin 4 місяці тому +1

    Here is how to do it, oh wait that's the wrong way do it like this???? Otherwise decent tutorial.

  • @AarushAggarwal-b1p
    @AarushAggarwal-b1p 3 місяці тому

    insane!

  • @RafinMiner
    @RafinMiner 11 місяців тому

    U g.o.a.t