How do I spawn a random Object from a Set

0 favourites
  • 7 posts
From the Asset Store
*********** Fidget popper tile sets **************
  • Hey,

    I searched the forum but don?t really found anything that fits for me, or i don?t really understand cause of language problems I guess.

    Here is my problem:

    I created 3 Objects at the moment, should be even more in the future, which are weapons and I want to spawn a random weapon every X second.

    I want to use the System->Every Second Action and a blank sprite as a spawn point.

    What do I need to do? Thanks in advance :)

    Beaverlicious

    PS: Sorry, if my english isn?t perfect! :)

  • You could use families; put all weapons in 'Weapons' family and use event 'Create Object' on the family. I recall this creates random member of the family.

    Other option would be to put all weapons in separate frames/animations of single sprite and on creation randomize the animation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thx for the fast reply:)

    The problem is, that i can't make families, because i don't have a license at the Moment. Need to save money first:)

    I don't want to use different animations as well, because i did it with objects already. Isn't there another Solution? Something like a randomize Event. Object 1,2,3 randomize or something!:)

  • There's no built-in way to select random objects, but you could make something yourself fairly easily:

    Create a global variable called randomiser, set it to 0

    • Every X seconds -> Set global variable randomiser to ceil(random(3))

    > Compare global variable randomiser = 1; trigger once -> Spawn object 1; set randomiser to 0

    Compare global variable randomiser = 2; trigger once -> Spawn object 2; set randomiser to 0

    Compare global variable randomiser = 3; trigger once -> Spawn object 3; set randomiser to 0

  • Hey, reads itself pretty logical, but what does ceil mean?

    Thanks a 1000 times guys :)

  • Ceil just means that it rounds the number up, as opposed to floor which rounds down, or round which rounds to the nearest whole.

  • thank you, thank you, thank you :)

    Used the code you wrote and i guess it works! Tried it a couple of times, didn�t think there�s a system :)

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