How do I have multiple instances of the same object interact

Get help using Construct 2

Post » Sun Jan 25, 2015 7:35 pm

I ran out of space in the title but, how do I have multiple instances of a single object successfully interact with each other?

I want to make a simple combat test. A single sprite object called player and they have instance variables: Dodge, strength, and health, and I want to be able to have it so that every second both objects are subtracting a random amount from the others health (because they are fighting). There are two instances of them on the screen, and they essentially target each other.

My problem is I don't know how to properly make the events for this because it is only one object. If I had two different objects then it would be easy, but I don't know how to use two separate instances of ONE object interact with each other as successfully as two different objects. Do you know what I mean? It's kind of hard for me to explain.

The method I'm thinking about is to have another instance variable called "target", and events depending on distance. So instance A gets close to instance B. Instance A's "target" variable gets the value of instance B's instance ID. And instance B gets instance A's. But I have no clue how the events would look like for this.

Please help! Thanks bye :)
B
11
S
2
Posts: 91
Reputation: 1,017

Post » Sun Jan 25, 2015 8:53 pm

Two instances or > 2? Maybe use a Family, or use their IID, or object indexing, e.g. Sprite(0), Sprite(1) etc. There are threads and/or tutorials discussing this.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Jan 25, 2015 10:50 pm

codah wrote:Two instances or > 2? Maybe use a Family, or use their IID, or object indexing, e.g. Sprite(0), Sprite(1) etc. There are threads and/or tutorials discussing this.


Could you direct me to them? I don't know what to search for when it comes to this question. It's a little complicated for me.
B
11
S
2
Posts: 91
Reputation: 1,017

Post » Sun Jan 25, 2015 11:03 pm

Basilboy wrote:
codah wrote:Two instances or > 2? Maybe use a Family, or use their IID, or object indexing, e.g. Sprite(0), Sprite(1) etc. There are threads and/or tutorials discussing this.


Could you direct me to them? I don't know what to search for when it comes to this question. It's a little complicated for me.


Maybe have a look at this one
https://www.scirra.com/tutorials/556/understanding-picking-with-respect-to-families
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Jan 25, 2015 11:19 pm

https://www.scirra.com/tutorials/556/un ... o-families

https://www.scirra.com/manual/75/how-events-work


well, not very helpful, but same problem here:
collision-detection-for-instances-of-same-object_t77217

all you have to do is to pick specific objects or ranges of objects within the family, to restrict, what happens to which. Otherwise it will happen to all objects of the same family. But that is the power of it (besides a better expandability).

Its a bit confusing at the beginning, but you have to take a look, which of the events actually pick objects, which don't, and so on...

Then you have to find your conditions, to get to the desired one. But you will find your way. Also great to google or search here. Its a complex theme... and is all written already loads of times.
B
8
S
3
Posts: 197
Reputation: 1,207


Return to How do I....?

Who is online

Users browsing this forum: Richterrii, robertg92 and 17 guests