How do I set collision results based on size?

Get help using Construct 2

Post » Mon Nov 24, 2014 10:34 am

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!
B
10
S
1
Posts: 72
Reputation: 1,015

Post » Mon Nov 24, 2014 11:06 am

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.
Image
B
54
S
24
G
12
Posts: 96
Reputation: 10,316

Post » Mon Nov 24, 2014 12:39 pm

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 -> http://www.programiz.com/c-programming/ ... ors-number
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Mon Nov 24, 2014 10:19 pm

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!
B
10
S
1
Posts: 72
Reputation: 1,015


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 10 guests