generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Motor issue

Previous Thread :: Next Thread 
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
28 Feb 2013 10:38 AM
I am using a motor to rotate an object based upon a CFrame of the objects position and the mouse's target (So a brick points at another brick) and have run into a problem:

Transitioning between -math.pi and math.pi causes it to go all the way around the long way, and vice versa.

How can I prevent this from happening?
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
28 Feb 2013 11:23 AM
math.pi was a half spin, or 180°

So to make it spin the way you want in degrees:

function getSpin(degree)
return math.pi/180*degree
end

For spinning 45 horizontal:

Part.CFrame = CFrame.new(Part.Position) / CFrame.Angles(0,getSpin(45),0)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
28 Feb 2013 11:31 AM
>_>

No, I dont want an alternative to math.rad. I want it to stop it from doing this:

At -math.pi/10 I try to transition to math.pi/10. Instead of going the math.pi/5 degrees, it goes math.pi*4/5 degrees, which takes quite a while (The motor is slow moving)
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
28 Feb 2013 11:36 AM
Change MaxVelocity for the speed, if that's the problem -.-
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
28 Feb 2013 11:38 AM
No no no.

The problem is that if the angle is almost at -math.pi and goes straight to almost math.pi, then the object has to rotate the ENTIRE way around CCW instead of CW (which takes much longer)
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
28 Feb 2013 11:40 AM
Just let it go to 0, wait until it's currentangle is 0 and then go further
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
28 Feb 2013 11:42 AM
So instead of moving 1/100th pi of a radian it needs to go 99/100ths pi of a radian, then teleport around 1 pi radian?

That's not what I want.
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
28 Feb 2013 11:43 AM
Sometimes the stupiest thing can be the solution -.-
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
28 Feb 2013 11:45 AM
That's not a solution, though.
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
28 Feb 2013 11:46 AM
Well, I think almost nobody understands your problem -.-
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
28 Feb 2013 04:53 PM
Well someone will.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image