#how to count a distance in studs
42 messages · Page 1 of 1 (latest)
Magnitude?
so you bounce a ball and you need to find out the distance it has traveled?
I think thats what he means
maybe something like
local distance = 0
local last_pos = ball.Position
RunService.Heartbeat:Connect(function()
distance += (last_pos - ball.Position).Magnitude
last_pos = ball.Position
end)
huh
that will just keep adding the distance to the distance
distance will be a huge number
a
what im saying it still keeps adding the distance to distance variable
like if its 1 stud away then its going to keep adding 1 to distance every heartbeat
wdym
RunService.Heartbeat:Connect(function()
distance += (last_pos - ball.Position).Magnitude
if its still then last_pos = ball.Position
it checks how much its moved every heartbeat
diagram
you are using += it just keeps adding the distance to the variable "Distance"
idrk
if the ball is at 0,0,0
last_pos is at 0,0,0
0 is added
next heartbeat it moves to 1,0,0
last_pos is at 0,0,0
1 is added
next heartbeat its still at 1,0,0
last_pos is at 1,0,0
0 is added
hmmm
makes sense ig
oh wait you werent updating the last_pos earlier so I thought u were trying to-
nvm
just checked the edited
modified discord client
I might or might not be using that
and I might or might not be saying that so discord might or might not ban me