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

How to simulate an object being thrown?

Asked by
Lacryma 548 Moderation Voter
8 years ago

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

0
Lots of CFrame. MessorAdmin 598 — 8y
0
Yeah lots of it... Hero_ic 502 — 8y
0
Actually, a much more efficient way is BodyMovers. DevChris 235 — 8y
0
Wow wow wow, didn't even think of that ogm. Lacryma 548 — 8y
0
I edited my answer and added a further resource TurboFusion 1821 — 8y

1 answer

Log in to vote
9
Answered by 8 years ago

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

0
Wow, thank you. Know anywhere i can learn more about this and related topics? Lacryma 548 — 8y
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. Goulstem 8144 — 8y
0
Great answer btw Turbo Goulstem 8144 — 8y
Ad

Answer this question