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

Help with Motors?

Asked by 8 years ago

Ok so ive read a few wiki articles about motors and rotation and all that and i went to implement my own through code by using the wiki example and for some reason its just not working at all can anyone help?

here is the code but i dont see anything thats wrong

script.Parent.Parent.Animate.Disabled = true
        local n = script.Parent.Parent.Torso['Right Shoulder']
        n.MaxVelocity = -.4 
        n.DesiredAngle = -math.pi
        repeat 
            wait() 
        until math.ceil(n.CurrentAngle) == math.ceil(-math.pi)

        n.MaxVelocity = .4
        n.DesiredAngle = -.5
        repeat 
            wait()  
        until math.ceil(n.CurrentAngle) == math.ceil(-.5)
        script.Parent.Parent.Animate.Disabled = false

1 answer

Log in to vote
0
Answered by 8 years ago

You've been doing it wrong. In order to change the Motor Rotation of a Motor, you have to use CFrame. The ROBLOX Wiki doesn't explain it very well, but I'll give you an example.

motor.C0 = motor.C0 * CFrame.Angles(0,0,math.pi/2)

Set the motor variable to your motor, then mess around with the CFrame.Angles() parameters until you get what you want.

In case you didn't get that, I'll explain. A joint has two CFrame properties, C0 and C1. C0 is the attached object, which in your case is the players Right Arm. C1 is the object C0 is attaching to, which is the Torso, as the Right Arm is attached to the Torso.

math.pi is a half turn, but from your last question I think you wanted a 90 degree turn. since math.pi is a half turn, and you want a quarter turn, just divide it by 2 and voila! Quarter turn.

I hope you got that. Good luck.

Your welcome.

0
How was that? OMEGA27304 8 — 8y
0
Thanks for that, It's really helping me! sloss2003 0 — 5y
Ad

Answer this question