Spawn object depending on instance variable

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi again!

    A little problem is bugging me!

    I have object with all unique instance variable. For this example i will take:

    Object 1. : Instance Variable: [number] = 1

    Object 2. : Instance Variable: [number] = 2

    Object 3. : Instance Variable: [number] = 3

    Now i want to:

    IF Instance Variable [number] = 1 SPAWN Object : Spawn1

    IF Instance Variable [number] = 2 SPAWN Object : Spawn2

    IF Instance Variable [number] = 3 SPAWN Object : Spawn3

    How i started:

    For each Object ( family for Object 1, Object 2 and Object 3 )

    ???????????????????????

    Object Spawn ??????????????

    I am thinking in a way of calling all instance variables the name of the object i want to spawn.

    But as far as i know there is no way to spawn a object with the name of a instance variable am i right?

    Though that is what i try to make.

    I will try with another example:

    Object: Apple , instance variable: fruitName = Apple

    Object: Pear , instance variable: fruitName = Pear

    Family: Fruit ( including Apple, Pear )

    EVENT:

    For each Fruit

    ACTION:

    Spawn {{OBJECT: Fruit.fruitName}}

    But that isn't possible..

    I hope i made myself clear once again.

    Thanks in advance!

  • All in the same event, no loop:

    event:

    compare 2 variables: object1.variable equal 1

    compare 2 variables: object2.variable equal 1

    compare 2 variables: object3.variable equal 1

    action:

    spawn

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi Lennaert,

    Thanks for your reply. Yet i do not understand what you mean..

    Can you take the Fruit example for this one? Thanks !

  • I thought you wanted to compare three fruits to select one item to spawn ... somehow lol

    Anyway, you will need to create some sort of list which assosciates a variable with an object.

    fruits.fruitname

    event

    compare 2 variables: fruits.fruitname = apple

    action

    spawn apple

    event:

    compare 2 variables: fruits.fruitname = pear

    action: spawn pear

    event:

    compare 2 variables: fruits.fruitname = banana

    action: spawn spawn banana

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