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
 

Body Gyro rotation help. (CFrame manipulation) :(

Previous Thread :: Next Thread 
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
11 Aug 2012 08:34 PM
So I'm trying to get my lovely ship to rotate. Yes?

Ok, so I'm using a BodyGyro....

This is my code to get the right position....


local Direction = VehicleSeat.CFrame
local AngleX, AngleY, AngleZ = Direction:toEulerAnglesXYZ()
BodyGyro.cframe = CFrame.new(Direction.p) * CFrame.Angles(0, (AngleY % math.rad(360)) + VehicleSeat.TurnSpeed, 0)

Basically, it takes the CFrame of the vehicle seat,r emoves the X and Z directions, and takes the Y angle and adds in the new rotation. I tried applying Modulus to it (But that shouldn't effect it at all, should it, unless it fixes it). The problem is this:

The rotation of the ship gets stuck at -270 and 90. So I only have a 180 turn around. I would like to be able to turn around in any direction I please.

I think it has something to do with the toEulerAnglesXYZ. I haven't learned a whole lot about Euler angles, but I suspect that's the problem.

Anyway, why would this line:

CFrame.new(Direction.p) * CFrame.Angles(0, (AngleY + VehicleSeat.TurnSpeed, 0)
-- Same line without Modulus

Stop rotation at -270 and 90? If it isn't a toEulerAngles problem, then what could be wrong.

If it is a toEulerAngles method problem, then how can I neutral/control rocking of the boat (I.E. the X and Z axixes), without using the toEulerAngles method?

Anyway, I suspect there is something wrong with the toEulerAngles, so if someone who is magical at CFrame / Gyros / Angles come over here and help)?

Thanks.
Report Abuse
DonnyTheDemented is not online. DonnyTheDemented
Joined: 29 May 2010
Total Posts: 1413
11 Aug 2012 08:44 PM
My guess is that fault lies in CFrame.Angles()

I see what you are doing, and I don't think the problem is toEulerAnglesXYZ()

Have you tried

CFrame.fromAxisAngle(v, r)
Report Abuse
DonnyTheDemented is not online. DonnyTheDemented
Joined: 29 May 2010
Total Posts: 1413
11 Aug 2012 08:50 PM
local Direction = VehicleSeat.CFrame
BodyGyro.cframe = Direction.p * CFrame.Angles(0, VehicleSeat.TurnSpeed, 0)

I believe this will serve your propose. Not sure why this works, but yea fault was in how CFrame.Angles() calculated the rotated CFrame
Report Abuse
DonnyTheDemented is not online. DonnyTheDemented
Joined: 29 May 2010
Total Posts: 1413
11 Aug 2012 08:51 PM
*purpose
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
12 Aug 2012 10:38 AM
Ummm.... That doesn't work at all. The VehicleTurnSpeed value is a 0.14 to -0.14 value, so you get about 16 degrees of rotation.

Also, you can't use a Vector3 as a CFrame value, so you have to do...

CFrame.new(Direction.p)

Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
12 Aug 2012 11:13 AM
I think I found my problem:

> local X, Y, Z = CFrame.Angles(0, math.rad(80), 0):toEulerAnglesXYZ() print(Y*180/math.pi)
--> 79.999990842554

> local X, Y, Z = CFrame.Angles(0, math.rad(95), 0):toEulerAnglesXYZ() print(Y*180/math.pi)
--> 85.000017164084

> local X, Y, Z = CFrame.Angles(0, math.rad(100), 0):toEulerAnglesXYZ() print(Y*180/math.pi)
--> 79.999990842554


CFrame.Angles is WEIRD, or toEulerAnglesXYZ() is weird.

Report Abuse
sircfenner is not online. sircfenner
Joined: 29 Aug 2008
Total Posts: 2430
12 Aug 2012 11:16 AM
toEulerAnglesXYZ() only gives rough values - it's by no means ideal and shouldn't be used for such rotations. However it may have changed since I last looked. :/
Report Abuse
rayoma is not online. rayoma
Joined: 13 Nov 2009
Total Posts: 1911
12 Aug 2012 11:33 AM
toEulerAngles has never been accurate. If you want to get the actual rotation just do (direction-direction.p)
Report Abuse
DonnyTheDemented is not online. DonnyTheDemented
Joined: 29 May 2010
Total Posts: 1413
12 Aug 2012 09:13 PM
local Direction = VehicleSeat.CFrame
BodyGyro.cframe = Direction * CFrame.Angles(0, VehicleSeat.TurnSpeed, 0)

*facedesk*
Forgot to drop the .p when I copied...
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