How do I have multiple instances of the same object interact

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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

  • 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.

  • 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.

  • > 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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