#math angles
1 messages · Page 1 of 1 (latest)
** You are now Level 4! **
@paper bay what
well you want a platform to move in a circular pattern right?
i still haven't reached the part with attachments, i was thinking about constantly rotating the part and moving it forward
yah
i'm aiming for my part to rotate similar to the ones in obbies, but yeah
also do you happen to know any reason of my studio saying i'm offline when really i'm not?
idk but its definitely nothing
aand it kicked me out of my own server, again
it keeps on doing that and after some time i can't even team test / join roblox games
only for me though
for the platform you just have to weld the platform to another part and make that part spin
you should ask in #1006356488912121967 for that kind of bug
thought you'd know why
i find the middle point of the start and end points, that's where that part is located
then i spin it
buuut that doesn't quite work because the travel distance turns out to be a constant
can't give you my current code 'cause studio's not working for me
do you have a video of the platform?
no, but i can explain what i try to do
i tried to base it off of basic formulas
getting how much the platform should move, turning that into a value (seconds) and moving the platform that long
the formula in question being?
i have to rewrite it since studio's buggy and i can't get it back
do i also explain the logic or do i tell the logic to myself
(the logic behind it)
i'm pretty good at that
i'll explain aswell
okay so the part will move the length of a portion (angle / 360) of a circle's length
that's the distance
the velocity is 14 (studs/s), so speed = distance / 14
speed = pi * diameter* angle / (360 * 7)
that's it
pi * angle / 180 is the angle portion
diameter / 14 is the distance portion
studio loaded
local x, y, z, angle = part.Name:match("([^,]+), ([^,]+), ([^,]+), ([^,]+)")
local wantedPos = Vector3.new(x, y, z)
local originPos = part.Position
local speed = math.pi * (wantedPos - originPos).Magnitude * angle / (360 * 7)
local lastPos = part.Position
local direction = 1
local paused = false
local startTime = tick()
RunService.Stepped:Connect(function(_, deltaTime)
if paused then return end
local target = direction == 1 and wantedPos or originPos
local toTarget = target - part.Position
local distance = toTarget.Magnitude
if distance <= 14 * deltaTime then
part.Position = target
paused = true
task.delay(3, function()
direction = -direction
wantedPos, originPos = originPos, wantedPos
speed = math.pi * (wantedPos - originPos).Magnitude * angle / (360 * 7)
startTime = tick()
paused = false
end)
return
end
part.Position += toTarget.Unit * 14 * deltaTime * direction
local currentPos = part.Position
part.AssemblyLinearVelocity = (currentPos - lastPos) / deltaTime
local deltaAngle = math.rad(angle) * deltaTime / speed * direction
part.CFrame = part.CFrame * CFrame.Angles(0, deltaAngle, 0)
lastPos = currentPos
end)```
i admit to using chatgpt out of desperation
bro you are overcomplicating this
i usually do that
don't know why or how
my main idea is to update the position every frame while rotating the part aswell
yeah thats probably why
ouch 💔
okay but really using welds might be a better idea than this
i haven't learnt those yet
but i understand your idea
and i think i'm doing exactly that but a little more math
spoilers: they have nothing to do with scripting but they do with the engine's physics system
i think the formulas are wrong (forgetting about welds)
☝️
i'm trying to generalize the script for a thousand other parts
can i generate (or stimulate) the part using the middlepoint formula i had
for a hundred of them?
** You are now Level 5! **
create some distance between the platform and the part
can't really do
can't you just save the whole thing as a model once ur done building it so u can copy and paste it
i'm mainly seeking generalizing
if you want them all to have the same behaviour
i do
then ou can just copy and paste
copy and paste what?
from the scripting guides i've watched i understood that i should never do that
why shouldn't you
too much memory goes into creating the scripts
are you aiming for something like this?
platform in the distance, sorry for the red sky lol
when you can have one main handler script
exactly that
aight
well then just weld said platform to the damned part
and spin the part
thats literally it
generalization
so this is your setup right
the green is your "root"
the red is your platform
your root wants to be anchored
your platform needs to be unanchored
then you use a weld on your root, set the "Part0" property to the root, then the "Part1" property to your platform
same effect that you want though, no?
i'm still believing that there is a way easier way for my brain to handle non-welding solutions to this