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: Manipulating x rotation in accordance to objects orientation

Previous Thread :: Next Thread 
GreatOculus is not online. GreatOculus
Joined: 30 Aug 2009
Total Posts: 2103
10 Nov 2014 09:05 PM
I'm making a hover car. For it's functionality, I have used bodygyro manipulation via key pressing etc.

I've been trying to add an up/down directional effect for it. The only problem I'm having, is that it is manipulating the x .cframe property, depending on x in the physical workspace. I need it to manipulate the rotation according to the car.

I use the same method for y turning, but obviously the y pole doesn't change depending on what direction you're facing.

Help?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
10 Nov 2014 09:07 PM
Y is up. So Y changes if you rotate your car. X is up and down. It changes if you change your pitch. Z is roll.
Report Abuse
GreatOculus is not online. GreatOculus
Joined: 30 Aug 2009
Total Posts: 2103
10 Nov 2014 09:09 PM
Yes I am aware. That is exactly the problem.

It works currently - when your driving down the x axis. As soon as you turn and are driving down the z axis, manipulating the x control rolls you instead of turning up or down.

I could implement another 2 keys for manipulating the z, but that would be a last resort for me. I need the x manipulation according to the actual part itself, no matter which direction it is moving.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
10 Nov 2014 09:12 PM
No, I mean relative to your car.

Z is roll. X is pitch. Y is heading.

Globally (Not relative)
X is left and right
Y is up and down
Z is forwards and backwards


But if you're doing it the way you should, you only need to worry about the relative stuff.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
10 Nov 2014 09:12 PM
What is the part of the script determining the orientation?
It is a math problem, and I can't solve it unless I know what you're doing.
Report Abuse
GreatOculus is not online. GreatOculus
Joined: 30 Aug 2009
Total Posts: 2103
10 Nov 2014 09:13 PM
Yes.

It changing globally is bad. I need it to change relatively to the car, so that it doesn't matter which direction you're going.
Report Abuse
GreatOculus is not online. GreatOculus
Joined: 30 Aug 2009
Total Posts: 2103
10 Nov 2014 09:16 PM
I've taken parts in the middle out for the sake of length:

local yAngle = 0
local xAngle = 0

local Stats = {
Acceleration = 2;
MaxSpeed = 90
}

local turningU = false

function keyDown(key)
if Player ~= nil and Mouse ~= nil then
print("Player and mouse are not nil")
key = key:lower()
if key == "e" then
print("E pressed")
turningU = true
turningUp()
end
end
Mouse.KeyDown:connect(keyDown)

function turningUp()
while turningU do
xAngle = xAngle + 0.1
turn.cframe = CFrame.Angles(xAngle, yAngle, 0)
wait()
end
end

Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
10 Nov 2014 09:18 PM
CFrame.Angles(0, yAngle, 0) * CFrame.Angles(xAngle, 0, 0)

Not positive, but this might work.

Also, if you meant for this to be in degrees, use

CFrame.Angles(0, math.rad(yAngle), 0) * CFrame.Angles(math.rad(xAngle), 0, 0)
Report Abuse
GreatOculus is not online. GreatOculus
Joined: 30 Aug 2009
Total Posts: 2103
10 Nov 2014 09:23 PM
Thanks a ton. Works like a charm.

On a slightly unrelated note,

have any ideas on how I might stabilize it a bit? It spasms like crazy when turning.
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