Pick A Random Family [C2] [SOLVED]

0 favourites
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • 99Instances2Go

    Thanks, man. You obviously know what you're doin, but I've already implemented my ROJO modified code for this. I will process your solution at some point because it seems to be a long time programmer's solution.

    99Instances2Go

    Still tryin to do the shooting though with multiple image points. Not hard to setup with instance variables for each ship type, but gets complicated trying to control the rate of fire of many different ships.

    The simplest solution I had before, which worked very well, was:

    Every x seconds

    Pick a random instance Sprite -> Sprite - spawn bullet

    Replacing Sprite with a Family of say 20 sprites did not work (think they all fire simultaneously).

    Is System ->Pick Random Instance equivalent to Pick a Random Family Instance? Where is the family random instance picking or is it the same?

    Maybe I'm just not seeing that option anywhere.

    Found a Scirra tutorial on picking family instances and it will take hours to test absorb, but I do not believe I want to mess with UIDs or anything that fancy.

  • Whatever he sent you in PM can't be too difficult, it's quite simple to set up variables like this. The Family becomes an object, instead of picking a single object you are picking from all the objects in the family. Pick random instance > sprite, or you use Pick random instance > family. If you're going to make a game with some complexity you should get your head around the debug mode and looking at objects to see what their current states and variables are, then you'll have an idea of what has changed and what is set as you expected.

    As an example, you have ships. Ship A, Ship B and Ship C are all in a family called Ships.

    Pick a random instance Ship A. That will choose one object, a randomly selected Ship A.

    Pick a random instance Ships. That will choose one object, a randomly selected Ship A, Ship B or Ship C.

    You select a Family as though it is just another object but really it represents all the objects within it.

    They are useful for when you want to sometimes group events.

    For example in this game, if you wanted to say :

    Bullet A can damage Ship A

    Bullet B can damage Ship A

    Bullet A can damage Ship B

    Bullet B can damage Ship B

    You put the bullets into a bullets Family and the ships into a ships Family and then it becomes one event applied to all :

    Bullets (family) can damage Ships (family)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Scratch this.

    It does actually work!

    Just made a simple capx from scratch, so no idea what happened ha ha.

    Thanks for all the replies.

    This concludes tonight's presentation.

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