Interacting between different instances of an obj

This forum is currently in read-only mode.
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • So, hi!

    I have two objects, both of the same sprite/type, oPlanet.

    When one overlaps each other, how can it make it so something happens to one of the sprites, and something ELSE to the other?

    Like, if the first has X bigger than the second, how can I make it so X gets even bigger for the first, and Y smaller for the second, even though they're sprites of the same object?

    I know, very confusing. Please help me if you understood anything.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • lol couldn't tell ya. This has been a problem for me since I started making games. I've always wanted some sort of condition like so:

    If (Object with value A) collides with (Object with value B) then do something with (Object with value A)

    but I don't think it'll ever happen..can't really say why either, it seems pretty basic.

  • put the object into a family.

    on Object collides with Family

    ----Object do this

    ----Family do that

  • lol couldn't tell ya. This has been a problem for me since I started making games. I've always wanted some sort of condition like so:

    If (Object with value A) collides with (Object with value B) then do something with (Object with value A)

    but I don't think it'll ever happen..can't really say why either, it seems pretty basic.

    Well, that already exists. Just use sub-events and private variables. For example, let's say there's a sprite with pv 'myID'. Three instances of that sprite exist. Their pvs are set to "red", "green" and "blue".

    + On collision between sprite and sprite (this will put both instances on the sol)

    ++ sprite: Value 'myID' equal to "red" (this sub-event will only select the instance with pv "red" if it is already on the sol)

    ++ sprite: Value 'myID' equal to "green" (same as above)

    ++ sprite: Value 'myID' equal to "blue" (same as above)

    With such a construction any two (or all three) instances that collide, will react according to the sub-events. Of course, you could further narrow down with other conditions/sub-events. For example, 'for each' as a sub-event to the 'on collision'-event will loop only through the instances that are already on the sol (which are the instances that collided).

  • You can also use for each.

    The collision will act as a filter, if you do the for each after the collision condition. You can then use loopindex to pick in actions.

    +>Sprite on collision with sprite

    ->for each sprite sprite set value to loopindex

    Then there's also picking by position(closest).

    +>Sprite on collision with sprite

    ->sprite pick closest to 0,.y

    -->pick closest to .x,0 do stuff

    ->sprite pick closest to layoutwidth,.y

    -->pick closest to .x,layoutheight

    That works since usually two object don't occupy the same xy on collision.

    Edit:

    Didn't read Tula's last para, so yeah what he said with loopindex for good measure.

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