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

model a projectiles motion?

Asked by 4 years ago
Edited 4 years ago

Yes I have seen THIS post It does work but if you move the mouse far away (e.g space) it shoots it extremely fast the code that calculates it:


local hrp = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("HumanoidRootPart"); local t = 1 local g = Vector3.new(0, -game.Workspace.Gravity, 0); local x0 = hrp.CFrame * Vector3.new(0, 2, -2) -- calculate the v0 needed to reach mouse.Hit.p local v0 = (mouse.Hit.p - x0 - 0.5*g*t*t)/t;

I'm wondering how I can slow it down, (there's a max speed, e.g 25 studs/s)

GIF of it going very fast

Note: if you know of any better ways of doing this please say (e.g raycasting or something like that)

1 answer

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

You could limit the velocity like this

local v0 = (mouse.Hit.p - x0 - 0.5*g*t*t)/t;
v0 = v0.unit * math.min(v0.magnitude, MaxVelocity)
Ad

Answer this question