|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|