1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Bumping balls

Discussion in 'Programming' started by Petrik33, Nov 6, 2019.

  1. Petrik33

    Petrik33 Member

    Joined:
    Nov 5, 2019
    Posts:
    11
    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.
     

    Attached Files:

  2. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    49
    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.
     
  3. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,846
    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);
    }
    
     
  4. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    49
    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.
     
  5. Petrik33

    Petrik33 Member

    Joined:
    Nov 5, 2019
    Posts:
    11
    Thank you all but im not using Gamemaker physics. Try to use my own to get an experince.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice