• 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!

Bumping balls

Petrik33

Member
Hi, everyone. And I really need your help because my script doing physics of ball colisions is pour and I guess I need a new one. So please if you have a script or ideas of making it to Find angle of balls(circles) moving and their speed after hitting each other , please, help and share it with me. I am only beginner and I cant solve this problem. This is how the game looks now to understand problem better, please no jokes that the problem is this game itself, its only prototype.
 

Attachments

R

robproctor83

Guest
If your using normal speed variables you can use move_bounce_all() or move_bounce_solid() and it will do what you want. If you have a real physics room they should bounce automatically if you have correct physical properties set.
 

Yal

🐧 *penguin noises*
GMC Elder
You could use motion_add to add half of each ball's current speed to the other ball (save both balls' speeds to a variable first so you don't lose it):
Code:
var ps1, ps2, pd1, pd2;
ps1 = speed;
pd1 = direction;
ps2 = other.speed;
pd2 = other.direction;
motion_add(pd2,ps2*0.5);
with(other){
  motion_add(pd1,ps1*0.5);
}
 
R

robproctor83

Guest
Ah, good point Yal, move_bounce_* would only bounce the colliding ball, which wouldn't look very realistic if the other ball didn't move too.
 
Top