How do I Crush Sprites? [IMG EXAMPLE]

Get help using Construct 2

Post » Sun Feb 05, 2017 8:48 pm

Hey guys. I'm trying to properly implement crushing sprites. I want to be able to defeat some blob enemies by crushing them with a box. Now I know there are many ways to implement this but I'm trying it against a tilemap surface when the box is approaching the sprite at high velocities. Also, the box should be able to crush it from different angles. Meaning the sprite can also be crushed on the ceiling. Now this is the code I used:
Image

My problem is illustrated in the picture below.
While I'm able to achieve the desired results as you can see with the first and second examples:

Image

At the third example the pink box is also destroyed even if it isn't being crushed but only because it's overlapping the tilemap at an offset when it's the one falling on the metal box. How do I make it so it only gets destroyed when getting crushed?
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Sun Feb 05, 2017 10:19 pm

Depending on where the hotspot is, the pink box should always have a greater y than the brown on when they are overlapping.
Image ImageImage
B
172
S
50
G
183
Posts: 8,440
Reputation: 115,599

Post » Sun Feb 05, 2017 10:59 pm

Dont really understand why it works at all. On collision the squared speed should be close to zero.
I dont know how many VulneraBox's you have.
Assuming there are more then one ....
I would:

Give the VulneraBox a instance boolean 'CanCrush'.

VulneraBox > Compare velocity ... overall velocity .. > .. 400
_______ VulneraBox > Set boolean 'CanCrush' .. true

VulneraBox > Compare velocity ... overall velocity .. <= .. 400
_______ VulneraBox > Set boolean 'CanCrush' .. false

VulneraBox on collision with TM_box
VulneraBox > Is boolean instance variable set ... 'CanCrush'
________TM_box > destroy
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Feb 06, 2017 4:12 am

newt wrote:Depending on where the hotspot is, the pink box should always have a greater y than the brown on when they are overlapping.


Actually I did consider this. But here's the catch: It's a rotating layout. I'm actually thinking of inserting a decoy sprite to be used as the relative 'higher Y' that keeps its position relative to the viewport.
I'll have to do some tests.

Also I forgot there's a 3rd case I just thought of last night:

Image

For this case I'm thinking of put Tilemap and BOX_METAL inside a family (if C2 allows) and replace the:

overlapping TM at offset with

overlapping SOLID_FAMILY at offset.

Now hypothetically using the hotspot method it should work but I'm anticipating a whole other set of problems.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Mon Feb 06, 2017 4:15 am

99Instances2Go wrote:Dont really understand why it works at all. On collision the squared speed should be close to zero.


Oh actually the illustration isn't clear. In that case, both VULNERABOX and BOX_METAL are sliding down thus both reached the maximum velocity.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Mon Feb 06, 2017 4:42 am

MPPlantOfficial wrote:
newt wrote:Depending on where the hotspot is, the pink box should always have a greater y than the brown on when they are overlapping.


Actually I did consider this. But here's the catch: It's a rotating layout. I'm actually thinking of inserting a decoy sprite to be used as the relative 'higher Y' that keeps its position relative to the viewport.
I'll have to do some tests.

Also I forgot there's a 3rd case I just thought of last night:

Image

For this case I'm thinking of put Tilemap and BOX_METAL inside a family (if C2 allows) and replace the:

overlapping TM at offset with

overlapping SOLID_FAMILY at offset.

Now hypothetically using the hotspot method it should work but I'm anticipating a whole other set of problems.


Um layer, or layout rotation don't change object y values, and you still have the same circumstances in the third case
brown overlaps pink
-pink has greater y than brown
It's just a matter of picking
You can filter that the other way
brown y is less than pink y
-brown is overlapping pink
Image ImageImage
B
172
S
50
G
183
Posts: 8,440
Reputation: 115,599


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests