#I need help implementing a randomly weighted spawning system
1 messages · Page 1 of 1 (latest)
Hello! What are you trying to achieve with this code?
Code looks fine I guess, you want to print the position of the ball that was spawned? Or to print the "ball number" that was spawned?
What I am trying to achieve is a weighted rng system that spawn so said ball with the random position range
Well right now you only have one ball so I don't even know how you plan to proceed
You need, at the very least, an Array of PackedScenes with different balls
IF you're instantiating different balls with different properties this should be fine, you'd just call the init function with the position
But you want the positions to be randomly placed?
Essentially you'll need to just write an x,y rng so have a minX maxX minY maxY and then randomize inside of that and add any weighting you need
plus you could add colliders to them so that they space themselves out a bit if too close on spawn?
Well he said "which ball" implying different balls
Also randi_range(0,0) is 0 at all times, you can replace that with 0
I have 3
sorry
should've been more specific
yeah i could but i only intend to spawn 1 every 3 seconds
Okay well you need to create an Array of PackedScene to hold them all, then use rand_weighted() to draw an index