Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to calculate a ball throw?

Asked by 4 years ago

i want to make a game in which you can point at a location in the map and a tool will be thrown there with and parabola curve but i could not think of a way to do this in roblox

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

there is easy way to do it.

  1. Roblox has gravity, when the ball moves, the gravity will pull the ball to the ground.
  2. You set a speed to the ball, the ball will move through the space without your control.

so one script

    ball.Velocity = directionVector * speed    
    -- something like Vector3.new(0.5,0.2,0.5) * 200

will make your ball fly.

However, it you have to make the tool hit that target, it will not be easy. you need to build the formula,

  1. calculate how many seconds it takes the ball from current height to hit the ground
  2. how fast the speed needs to be in order for the ball to reach the target in that many seconds you just calculated above.
  3. make sure you ball fly out flat, if you throw the ball up an angle, you just make the calculation more complicated.
Ad

Answer this question