#Score Based Respawning

1 messages · Page 1 of 1 (latest)

neat geyser
#

Hello! I'm extremely new to Godot, and just finished an Astroids tutorial! Though, it didn't cover how to make the asteroids actually respawn, so I decided to take that as homework.

I want to make it so that every time an interval of 525 score is reached, a new large sized asteroid spawns! The first image was my first idea, but it didn't end up working out. The position was just to test, and it's where the asteroids initially spawned are grouped into! Though, it did cause the line shown in image 2 in the debugger, which is in reference to image 3.

If anyone's willing to work with me on figuring this out, it would be very appreciated! Ping me if you'd be willing to assist

#

Oh, and here's these too if they help!

opaque falcon
#

If statements work as a series of "is this thing true or false?" questions.
If the thing you are claiming is true it will run the code inside it.

if score + 525 means "if score +525 is true:"
I think int other than 0 always evaluate true, so it's probably always true.

You are gonna need some math for that.
if score % 525 == 0: would be true for any multiplier of 525
% is the modulo operator.
It basically divides the number and checks what is left over after division.
525 divided by any multiplier of 525 would be 0.
(It would be something else for every other number.)

But if you went from score of 524 to score of 526 it'd skip and not help you...
I've seen something like this before:
if current_score % 525 > new_score % 525:
I'm pretty weak at math, so I'm not 100% sure if that works.
Some of the other people on this server are really good at math, maybe they know an easier way to do it.

The warning about shadowing happens when a local two thing have the same name as a thing up top does in the same script.
If you do var cool_thing up top and then inside a function you do var cool_thing a second time, you are creating two things with the same name (which can be confusing), so it warns you.

Also that way of using .connect("signal_name, callable) works, but I find it less error prone to do some_node.some_signal.connect(callable) because then you aren't relying on text strings.

neat geyser
#

I see, I see

#

Good news, the signal definitely worked!

#

Bad news is the remainder statement I added definitely did not LMAO

#

This is what I did

neat geyser
#

Okay, update

#

Trying this now

#

Not working but it did stop spawning stuff every time an astroid exploded so that's a half win