Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to make a baseball game in unity?

Discussion in '2D' started by maxmedina05, May 13, 2014.

  1. maxmedina05

    maxmedina05

    Joined:
    Jan 9, 2014
    Posts:
    4
    Any idea how can i determine the direction the ball is going to go when the bat hits the ball?
     
  2. DexRobinson

    DexRobinson

    Joined:
    Jul 26, 2011
    Posts:
    594
    Math, lol....

    No but for real you can do it a couple of different ways. You can make it simple or complex depending on your level of skill and knowledge. Your math equation could look something like this though...

    ballDirection = angleOfBat * powerOfSwing * positionOfContact;
    forceOfBall = speedOfBall * gravity * massOfBall * powerOfSwing;

    Or you could just have a hit/miss system. Then if they hit the ball if will randomly choose if it's going to be a single,double, homerun, etc. Everyone loves RNG.


    Idk, something like that I am not the best at these things but hopefully it will help a little.
     
  3. maxmedina05

    maxmedina05

    Joined:
    Jan 9, 2014
    Posts:
    4
    Thank you