How do I handle collision between two same objects with instance variables?

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi.

    I'd like to detect a collision (actually an overlap) between an object and another instance of that object.

    Found on multiple threads in the forums that it's best to put the object into a family and then detect the overlap between object and the family.

    That works, but I then need to compare instance variable between these two participants of the event. How?

    E.g. The object has a Strength instance variable. How do I get this value from the other object (referred to as Family)?

    Thanks!

  • I know what you mean about the family logic but I tend to avoid this. If you approach it with 'pick nth instance' then you can grab the variables from the two instances, I believe ordered by UID. If you do an overlap condition then you can use pick 0 and 1 instances to get their values separately.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • lionz

    Thanks, great suggestion. I actually also dislike the way with the family because it feels clunky, and would much rather work with the two objects directly. However, unless I'm doing something wrong it seems that the following logic just doesn't work:

    On Drag Ended -> If Sprite1 is overlapping Sprite1 -> do something.

    The "do something" action just doesn't trigger, whereas it does without any problems when it's Sprite1 overlapping a Family.

  • Well if I think of it in terms of the Family logic you can add all variables at the Family level then you should be able to compare Sprite with Family.

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