• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

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

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);
}
 
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