|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 22 May 2011 |
| Total Posts: 1015 |
|
|
| 28 Feb 2013 11:43 AM |
| Sometimes the stupiest thing can be the solution -.- |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2013 11:45 AM |
| That's not a solution, though. |
|
|
| Report Abuse |
|
|
einsteinK
|
  |
| Joined: 22 May 2011 |
| Total Posts: 1015 |
|
|
| 28 Feb 2013 11:46 AM |
| Well, I think almost nobody understands your problem -.- |
|
|
| Report Abuse |
|
|
| |
|