Grenade Arc: Advice Requested

Hello developers!

Today I come to you in need of scripting help. My problem is simple enough: I need a grenade to be thrown when the player clicks. I can do all the stuff before the toss and on detonation, but I am unsure of the best method for ‘launching’ it. The player will be able to input power and angle to get the grenade on its path. What sort of physics mover or modifier would you recommend to accomplish this goal?

3 Likes

I’d most likely use Body movers.

Yes thank you… which one(s)?

1 Like

A ballistic trajectory can be obtained by simply setting the Velocity property of the grenade’s primary part.

An easy way to get the direction would be:

local target = --(position of mouse click)
local source = --(position of thrower)
local angle = --(angle of throw)
local power = --(throw strength)
-- Create a CFrame pointing at the target in the XZ plane, then angle up.
source = source * Vector3.new(1, 0, 1)
target = target * Vector3.new(1, 0, 1)
local direction = (CFrame.new(source, target) * CFrame.Angles(math.rad(angle), 0, 0))
-- Then multiply the unit vector by power.
local velocity = direction.LookVector * power

You may need to adjust the power value to make sure the grenade travels far enough.

7 Likes

I’d use BodyPosition. Simple and easy to use, interacts with physcis so that’s a plus.
You could also go with @Blokav 's suggestion which would also work and may actually be preferable.

2 Likes