So I want to make bodygyro rotate my rocket slowly to 90 degrees. This should work?
local bg = script.Parent.Parent.StageThree.ThirdStageFuelTank.BodyGyro
while true do
wait()
bg.CFrame = bg.CFrame * CFrame.Angles(math.rad(90), 0, 0)
end
So I want to make bodygyro rotate my rocket slowly to 90 degrees. This should work?
local bg = script.Parent.Parent.StageThree.ThirdStageFuelTank.BodyGyro
while true do
wait()
bg.CFrame = bg.CFrame * CFrame.Angles(math.rad(90), 0, 0)
end
Just to let you know, I think it should work but my rocket just jerks and doesnt rotate.
Could it be to do with Cancollide?
How massive is your rocket? If it’s super heavy it’ll take a lot of torque to rotate it - so make sure you’ve set MaxTorque high enough.
maxtorque at inf. i think i may of found the reason but lemme test real quick.
No luck. Max torque is at inf and my p is at 100. SHould rotate but i just jerks in one spot.
Ah, I see why. Every 1/30th of a second you rotate the target CFrame by 90 degrees. That would be like spinning really fast on the X axis. There BodyGyro can’t keep up, so the while loop goes around way faster than the actual rocket, causing it to go more than 180 degrees “in front of” the BodyGyro. That means the shortest way to reach the desired CFrame is constantly changing back and forth between -X and +X, which explains the “jerky motion” you described. Try 1
instead of 90
, or even less.
Ok, will try now and let u know.
Ahh ok I see exactly what you mean. If I change the rotate to 1 then it goes back and forth which explains it. Is there a way to make it rotate to 90 degrees and stop? Maybe I need BodyAngularVelocity?
You then need a for loop. The following loops 90 times and adds 1 degree to the rotation each time.
for i = 1, 90, 1 do
wait()
bg.CFrame = bg.CFrame * CFrame.Angles(math.rad(1), 0, 0)
end
It works, ish. I need dampening but with dampening it deosn’t rotate to 90 degrees. Without dampening it just keeps rotating.
Any way to make it stop at 90 degrees and for it to be a slow rotation?
Just set the CFrame to the desired angle (no for loop needed) and tune the MaxTorque to a lower value.
Hey, I did what you told me but it still doesn’t work. heres my script.
local bg = script.Parent.Parent.StageThree.ThirdStageFuelTank.BodyGyro
bg.MaxTorque = Vector3.new(0,0,400000)
bg.P = 100
while true do
wait()
bg.CFrame = bg.CFrame * CFrame.Angles(math.rad(90), 0, 0)
end
local bg = script.Parent.Parent.StageThree.ThirdStageFuelTank.BodyGyro
bg.MaxTorque = Vector3.new(0,0,400000)
bg.P = 100
bg.CFrame = bg.CFrame * CFrame.Angles(math.rad(90), 0, 0)
Now it’s just not rotating. No errors just doesnt rotate. No anchors
Works. I will probally have to mess around with the maxtorue and stuff to make sure it rotates all the way but doesnt rotate back. And btw, it doesnt rotate all the way.
I don’t know if I’m stupid. But I can’t seem to get the BodyGyro to do a slow rotation. The rotation is quite instant. It does rotate smoothly. But only when I set the angle to 45 and have the P and D at a ratio of 1:1.
I would like the BodyGyro to complete the rotation over maybe a span of 5 minutes. I have tried changing maxtorque but it has no effect. UPDATE! I AM SUPER HAPPY and proud of myself for creating a simple loop
x = 1
x = += 1
repeat
bodyGyro.P = bodyGyro.P + x
wait(2)
until( bodyGyro.P == 1000 )