• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Can I set different things to happen depending on how much two objects colide?

F

Filip Spasic

Guest
So I have two clouds, one player cloud and one enemy cloud. What I want is, if I hit the enemy cloud, I die, but if I only scratch the enemy cloud with my player cloud, I charge with electricity. Is there a way to have these different conditions happen based on how much the collision boxes overlap? Im open to any idea on how to make it
 

samspade

Member
Lots of ways probably. My suggestion would be this. Do check for a collision with the cloud directly. Have the player cloud spawn two hit boxes, one smaller than the other, and check for collisions with those.

If the cloud is a circle (or oval) you can do your own collision checking, but if it is an oval then that will take probably learning a little bit of math
 

Bentley

Member
You could measure the distance when they collide:

var dist = point_distance(x, y, x2, y2);
if (dist > scratch_dist) // die
else charge_meh

Something like that mb.
 
Top