An Aircraft Display System

Hey, so I am trying to re-create an airbus A320 PFD(if you don’t know what a PFD is, it is a Primary Flight Display that shows airspeed, altitude etc.).

I have a template I have tried to go off, except I cannot manage to make it work.

When a block is rotated (shown below), the rotation of the ground/sky rotates. I would like it to be almost realistic as possible to the IRL one in an A320.

I have tried asking multiple programmers I know, but still didn’t get anywhere.

Is there anyway I can make this work?

Thanks.

And you want it to not do that? Is that the question?

If you haven’t seen what a pfd does, it rotates up down and sideways. I am trying to replicate that almost identical from using a blocks rotation.

What about grabbing the X/Z orientation and connecting that to the
image
Surface UI?? via heartbeat/renderstepped
And then the UI rotation is the same as the part rotation

Edited to correct this paragraph because I’m a moron.

I think this is probably what you are looking for. This only handles the roll on the Z axis in radians as it will be required to rotate the GUI, but you can adapt it to get the pitch as well.

local function GetRollAngle(orientation:CFrame)
	local target:Vector3 = orientation.ZVector:Cross(Vector3.yAxis)
	local angle:number = math.pi-math.acos(target:Dot(orientation.XVector))
	if orientation.RightVector.Y > 0 then angle = -angle end
	return angle
end

Okay, so how would I connect it, could it managed by doing something similar to this?

while wait() do
    frame.Rotation = GetRollAngle()
end
1 Like

I’ve heard some people do it, but i’m unsure, i will need to give it a try.

You would need to send the CFrame of the aircraft to the GetRollAngle function and you will also probably need to convert to degrees. Otherwise yes, just put it in a loop. I actually recommend using RenderStepped for this in a LocalScript.

Okay, I’ve given it a try and it hasn’t rotated?

This is the code:

local function GetRollAngle(orientation:CFrame)
	local target:Vector3 = orientation.ZVector:Cross(Vector3.yAxis)
	local angle:number = math.pi-math.acos(target:Dot(orientation.XVector))
	if orientation.RightVector.Y > 0 then angle = -angle end
	return angle
end


local Display = script.Parent
local block = workspace.Sensor
local run = game:GetService("RunService")

run.RenderStepped:Connect(function()
	Display.P.Rotation = GetRollAngle(block.CFrame)
end)

You need to convert to degrees if I’m not mistaken.
Display.P.Rotation = math.deg(GetRollAngle(block.CFrame))
Also make sure the Z side of the block is forwards and the X side points towards a wing.
If that doesn’t work, go ahead and print the angle to see where the problem is. I’ll be away for close to 20 hours, hopefully you can make some progress without me for a bit. Good luck!

Alright I am gonna give that a try, hopefully I should be able to replicate it, I may add it has to run on a server side. (It doesn’t work in client, works on the server).

I have still given a go, tried a few different ways, it still doesn’t work against either.