How do I set collision results based on size?

0 favourites
  • 4 posts
From the Asset Store
220 Food Sprites in 16x16 pixel size. Perfect for items for a retro style game.
  • Hey everyone!

    I have a question relating to collisions and instances that is currently confusing me no end, and I was wondering if anyone could help me?

    Basically, my game will have multiple instances of one object, which will differ in size/scale. Ideally, I want to make it so that when various instances of these objects collide, the biggest instance of the object absorbs the smallest/smaller one/s.

    How should I go about this? I was thinking it may be something along the lines of sub-events with triggers relating to 'Pick by Evaluate', but I'm fairly new to Construct 2 and thought I would ask the wisdom of experts.

    Any help anyone can give will be greatly appreciated!

  • I guess this calls for instance variables.

    Create an numeric instance variable called 'size' (or whatever) for the block.

    Set the instance variable of each block to its size.

    Then in your 'on colission' event, compare these variables.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On a collision event with the object instances grab the objects width and height to calculate the areas. Add them together and destroy one. Then find the factors of that number and pick some in the middle and set that to the new height and width of the remaining object.

    Finding the factors will be the trickiest part but you can use this as pseudo code -> ... ors-number

  • Thanks for all your help guys! That is really helpful!

    TheWyrm unfortunately, I tried to implement what you explained about the factors and setting the new size, but to no avail. I'll have to look into this aspect of things a bit further!

    Anyway, thanks for all of your help!

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