Action Between Same Object Different InstanceValue

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello guys, I want to ask question regarding action that involve same object but different in instance value.

    For example: I make one ball which have instance value "color". When the instance value is set to "red", the color become red. "Blue" become blue.

    The question is I want the red ball to destroy the blue ball when colliding.

    Is that possible?

    Thanks!

    <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Create 2 variables in the object.

    Name one "colour" and set each instances value in the editor to "red" or "blue".

    Name the other variable "overlapping_instance_ID".

    add the event

    object ball overlapping ball

    set action

    set "overlapping_instance_ID" to unique ball ID.

    Create a subevent, and set the condition to

    pick instance by unique id, and set the value to the variable "overlapping_instance_ID".

    Now add another condition to the event, ball variable "colour" = "red", set action to destroy ball.

    Alternatively you can use another object as a detector, do a for each loop on all balls named blue and set the detector to their position, then do another event and if detector overlapping ball and ball colour is red then destroy ball.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ethan Big thanks to you mate! <img src="smileys/smiley4.gif" border="0" align="middle">

    I applied your logic and here are the results:

    First logic

    <img src="http://imageshack.us/a/img199/6254/test2n.png" border="0">

    Capx: http://dl.dropbox.com/u/70239636/test1.capx

    Result: When red object overlap with another red object, both destroy. I don't know, maybe I got it wrong somewhere.

    Second logic

    <img src="http://imageshack.us/a/img685/3916/test1kj.png" border="0">

    Capx: http://dl.dropbox.com/u/70239636/test2.capx

    Result: Work accordingly, although when I use For Each (Once), the collision object created every tick, I wonder if it is a bug. I want to test it with newer C2 version, but download keep failed.

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