Random Object Spawn Issues

0 favourites
  • 5 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • I'm having an issue spawning random objects. First, here's the section of my event sheet that isn't working as I hoped it would:

    <img src="http://i216.photobucket.com/albums/cc212/darkstorne/Events_zps3c051dc5.png" border="0" />

    I have another event that constantly subtracts from the value "NextObject". When the value of "NextObject" reaches 0, the game should spawn a random object further along the path, just off the screen (it's an endless runner). But for some reason, it only spawns an object the first time, and always the first object on the list (Rocks1, which is the default value for the variable used to choose which object is spawned). After that first object... nothing.

    I've also attempted setting this up with the different random object variables as sub events, but then nothing happens at all (even if I remove the "trigger once" conditions).

    This is strange, because I use a very similar system to generate enemies which works fine. Only difference is the enemies each have their own countdown global variable, so no extra step that randomises which enemy is spawned. That's making me question whether the random variable is working? I can't see where I made a mistake though.

    Any help would be greatly appreciated! Thanks for reading <img src="smileys/smiley12.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Aaaaand... I posted this in the wrong forum section. Sorry <img src="smileys/smiley9.gif" border="0" align="middle" />

  • silver

    Have you tried int(random(5)) as unlike classic,C2 will not return an integer automatically?....

  • That worked! Thanks!

    For some reason the other sections where I've used 100 + random(1000) work fine though. They don't need to be 100 + int(random(1000)). Odd <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Coming from classic myself,I have been caught out by C2's love of floats a few times...lol.

    If your other uses have been in regard to plotting x/y and you have pixel rounding on then that may explain why it has not surfaced yet..

    Glad to help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)