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

Anybody here a mathematician?

Asked by
roquick 41
6 years ago
Edited 6 years ago

Hi. I have two players & 1 target. Im basically trying to make both of them reach the target at the exact same time.

player 1 is traveling 16 studs per second & is 20 studs away from the target

player 2 is 120 studs away from the target

does anybody know what walk speed Player 2 needs to travel at to reach the target at the exact same time as player 1?

1 answer

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

Oh boy, I'm not a mathematician, not yet!

There is some simple algebra to use here. Let's step through it and implement it in a script.

we are given the speed of player 1. v1 = velocity of player 1 (well the magnitude of his velocity)

we are given three positions p1, p2, pt = position of player 1, position of player 2, position of target and therefore displacements (differences in position) d1, d2

we will leave time unknown because we don't care about, this means we will substitute to get rid of it in our equations in just a second

velocity is given by distance divided by time
v1 = d1/t
v2 = d2/t

t = d1/v1
v2 = d2/(d1/v1)

cool!

Now let's do this in a script.

local player1
local player2

local walkspeed1 = player1.Character.Humanoid.WalkSpeed
local position1 = player1.Character.Torso.Position
local position2 = player2.Character.Torso.Position

local target = Vector3.new(0,0,0) -- Just an example

player2.Character.Humanoid.WalkSpeed = (position2 - target).Magnitude / ( (position1 - target).Magnitude / walkspeed1 )

I answered this question with a script that describes how you would do it in any scenario. To answer your specific question.

v2 = 116 / ( 20 / 16) = 92.8 studs per second

1
thank you roquick 41 — 6y
0
Maybe a little bit late, however the equation you would set up should be - 20/16 = 120/x, x would be 96, so 96 studs per second. TakeItToTheM 0 — 1y
Ad

Answer this question