Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to simulate an object being thrown?

In a situation where an object is thrown, a rock or maybe even a grenade, how would you simulate the arc being thrown?

How would you be able to calculate the trajectory of the object?

When answering do not worry about the Z-Axis, I am asking this question in regards to simple 2D coordinates.

To visualize the motion I am trying to achieve, Trajectory

5 comments

0

Lots of CFrame.

0

Yeah lots of it...

0

Actually, a much more efficient way is BodyMovers.

0

Wow wow wow, didn't even think of that ogm.

0

I edited my answer and added a further resource

1 answer

✓ Accepted answer

Well, in physics, there are multiple formulas for the topic of trajectories. I'm assuming what you're looking for is the X and Y position of the projectile after a given time, given the angle of launch and the initial velocity.

First you need to find the velocity components for the X and Y values.

Vi = Initial Velocity

A = Angle of Launch

Vx = Vi * cos(A)

Vy = Vi * sin(A)

Now that we have the velocities in the X and Y directions, we can use that to get the position of a projectile after a specific amount of time.

T = Time in seconds

G = 196.2 (This is the acceleration due to gravity in roblox. In the real world, it's 9.81)

Px = Vx * T

Py = Vy * T - (0.5 * G * T^2)

Now we know the X and Y positions of a projectile at a given time.

You can use this to move a projectile by incrementing the time by small amounts and then positioning the projectile at the calculated location, or you can use this to predict the path of a projectile.

Hope this helped!

Further resources: Projectile Motion

3 comments

0

Wow, thank you. Know anywhere i can learn more about this and related topics?

0

Just googling math formulas for different aspects of physics is probably the best way - as in roblox this stuff is pretty specific and considered advanced.

0

Great answer btw Turbo

This discussion is preserved as it was. New answers, comments, and votes are closed.