how to create random object ?!!

0 favourites
  • 10 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi all !

    How to create Random object in Construct 2 ?!! <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Add the objects to a family, and then just System->Create Object->FamilyName.

  • hmm. How does that create a random object?

    It sounds like it would just create 1 of everything. So all that does is just generate 1 object randomly.. that is strange. Good to know though.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another thought would be to have a sprite strip of different objects and spawn an instance of the sprite to a random frame/Sprite in the strip each time...

  • I do it in a similar manner to what BluePhaze suggested, except that I use individual frames rather than a strip. Set the animation to be 0 fps and upon object creation a random frame is selected via: round(random(0,x)) where x is the number of frames/objects -1.

    Here is a basic example I whipped up:

    Another nifty command that can be used in a similar context is the choose command. Upon triggering one event you could randomly choose between the first three objects : choose(0,1,2) and upon another triggered event choose between the last 3: choose(3,4,5)

  • When you select a family with 'create object' it picks a random object from that family.

  • I have a question about your method thehen. So I setup my family and put the images inside. The object randomizes the images but it does them all and it keeps repeating instead of producing one and stopping.

    After reading some tutorials I was seeing that I should set the family as an instanced variable along with the objects inside. My issue is I cannot get the random to stop and I was wondering if you had a little more info or anything to point me in the right direction on this.

  • When you select a family with 'create object' it picks a random object from that family.

    can you post a example capx file please

  • Hi all

    tried to repeat original posted file.

    In my file random frames are chosen correctly, but when sprites start falling, all random instances are the same frame.

    Does happen because I haven't used "family" ?

    Also noticed that UIDs are different: original uid is 0, mine is 3


  • hmm, found the solution.

    Speed of animation should be set to zero

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