Obejcts with different instance variables

0 favourites
  • 7 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I have different objects with different instance variables for example projectile A,B and C and enemy 1,2,3. Each projectile makes different damage and each enemy has an differnt health value. The question is how i can pick the vars from one type to another without list up all objects on a codition "on collsion with"

    A good example are RPGs hundrets of weapons and hundrets of enemys... i can´t imagine that each enemy/weapon has a endless long list with "on collision with". it has to be a way to shorten everthing up to keep the clarity...

  • You can add all of the weapons to a family called weapon and all of the enemies to a family called enemy, then you can do weapon on collision with enemy.

  • i have triet this before but i get no access to the specific health/damage (and other) values of the objects... the point is to make only on "on collision" condition to substrakt the specific damage of a weapon selectet to the specific health value of an enemy... because weapons and enemys has totaly different values...

    The best would be on event sheet with alle enemies and their events and stats another one with all weapons and their events and stat and a third containsing all events of the player...

    on other words the player event sheet pick the stats form the weapon event sheet and deal the damage value wich on an enemies health wich is written on a thrid event sheet... all in all there should only be one single "on collision with" event in it... how can i do it???

  • When you use ProjectileObject On Collided with EnemyObject, only the objects involved with the collision are "picked". Then you can use expressions and instance variables in your action - Subtract ProjectileObject.DamageInstanceVariable from EnemyObject.HealthInstanceVariable.

  • Sigma83

    oosyrag is right, but fails to mention that these the variables should not be instance variables of the individual objects, but instance variables of the family.

  • Does noone has a solution? T_T

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's like oosyrag and briggybros said.

    Put all your enemies in a Family called 'Enemy' and put all of your projectiles in another called 'Projectile' for example.

    Give both families a 'family instance variable' (right click on the family name) with the names you want like health and damage. Now click in the layout-view in the left Objects-Windows of all of your objects one by one. If you click an object you will see on the right instance variable in the 'Objects properties'. Now you can give every object a individual value for health or damage.

    Now use:

    Projectile| On collision with Enemy -> Enemy| subtract Projectile.damage health

    The rest does construct do for you.

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