0 Favourites

Relations between instances

  • Hi, how can I create link between two instances ? In normal programming you can do this by setting "instance variable" on an object and then assign another object to this variable, but in construct it seems that only 3 basic types are allowed for instance variable: string, number and boolean.

    I would like to make connection between two objects, because I have tower (with turret behaviour) that shots bulets. Now when bullet hits enemy, i have no way to get somehow tower that has shot that bullet, but i need to get this tower because I want to increase experiance for it.

    Only way I see to do so is to put number variable on bullet, pass UID to that var while creating bullet and then add condition pick tower where tower.UID = bullet.tower_UID on the bullets with enemy collision event.

    Is there better aproach for such thing ?

  • Hi, how can I create link between two instances ? In normal programming you can do this by setting "instance variable" on an object and then assign another object to this variable, but in construct it seems that only 3 basic types are allowed for instance variable: string, number and boolean.

    I would like to make connection between two objects, because I have tower (with turret behaviour) that shots bulets. Now when bullet hits enemy, i have no way to get somehow tower that has shot that bullet, but i need to get this tower because I want to increase experiance for it.

    Only way I see to do so is to put number variable on bullet, pass UID to that var while creating bullet and then add condition pick tower where tower.UID = bullet.tower_UID on the bullets with enemy collision event.

    Is there better aproach for such thing ?

    Have an instance variable for your bullet (a number) called TowerID

    When you create your bullet, set it's variable to the unique Id of the tower that spawned it (Tower.UID if Tower is the name of the tower)

    Then you can later do :

    Bullet on collision with Ennemy:

    Pick Tower by UID TowerID : add experience

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • i was just about to submit a question like that, and the solution was amazing, thx a lot!

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