Obejcts with different instance variables

Get help using Construct 2

Post » Sat Mar 26, 2016 9:05 pm

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...
B
17
S
4
Posts: 9
Reputation: 893

Post » Sat Mar 26, 2016 9:45 pm

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.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Sat Mar 26, 2016 10:18 pm

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???
Last edited by Sigma83 on Sat Mar 26, 2016 10:32 pm, edited 1 time in total.
B
17
S
4
Posts: 9
Reputation: 893

Post » Sat Mar 26, 2016 10:25 pm

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.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Sat Mar 26, 2016 10:47 pm

@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.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Sun Mar 27, 2016 5:37 am

Does noone has a solution? T_T
B
17
S
4
Posts: 9
Reputation: 893

Post » Sun Mar 27, 2016 11:33 am

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.
B
24
S
3
G
1
Posts: 454
Reputation: 2,171


Return to How do I....?

Who is online

Users browsing this forum: rot1109 and 24 guests