How do I instance variable transfer

  • Hello,

    I would like to know how can I transfer instance variable to family variable e.g. from Enemy1, to Enemies family HP variable. There will be only one enemy randomly chosen from enemies family.

    I tried hard, but I have no idea how to do it. When there is enemy, I dont know which one has spawned, so I cant check if enemy should be destroyed or not.

    PS. Sry for bad english ;p

  • Take a look at this in the manualand this tutorial

    I cant use Monsters.HP (which HP is instance variable of certain monster). Im forced to use family variable, thats why I need to transfer it.

    The only way I found is doing it manually, however its really bad idea at all.

  • Still need help, bump.

  • You could use the system condition Pick random instance (choose a random instance, in this case you want a random instance of the family):

    "Pick a random instance from the currently picked objects. In other words, if Pick random instance follows another condition, it will pick a random instance from the instances meeting the prior condition. Otherwise it picks a random instance from all the instances."

    Store the Ennemies.HP value somewhere (since you picked a random instance, it ll be that instance that is concerned)

    Then pick all instances of Ennemies, and set their health to the value stored.

  • Store the Ennemies.HP value somewhere (since you picked a random instance, it ll be that instance that is concerned)

    Not sure how to store it somewhere, thats my problem at all.

  • Bump, still need help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would scrap using families for Monsters. Families are there to make the work flow quick and easy. When you are handling multiple monsters and instance variables, you need to do them separately.

  • I would scrap using families for Monsters. Families are there to make the work flow quick and easy. When you are handling multiple monsters and instance variables, you need to do them separately.

    Wait, you tell me to add 50 monsters separately and for each skill i should add 50 monsters which every lose certain amount of hp? Thats totally retarded imo.

  • Yes. Unfortunately, it takes a lot of work.

  • Yes. Unfortunately, it takes a lot of work.

    Wait, that means it will be really badly optimized, yup? It will work slowly on mobile devices.

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