How to calculate BodyGyro CFrame by using four corners

local RF = CFrame.new(Position.Position + Vector3.new(Size.X/2 , -Size.Y/2 , -Size.Z/2))
local LF = CFrame.new(Position.Position + Vector3.new(Size.X/2 , Size.Y/2 , -Size.Z/2))
local RB = CFrame.new(Position.Position + Size/2)
local LB = CFrame.new(Position.Position + Vector3.new(-Size.X/2 , -Size.Y/2 , Size.Z/2))

Right Front, Left Front, Right Back, Left Back

2 Likes
local Position = Vector3.new(0, 0, 0)
local Size = Vector3.new(4, 4, 4)

local RF = Position + Vector3.new(Size.X/2, -Size.Y/2, -Size.Z/2)
local LF = Position + Vector3.new(-Size.X/2, -Size.Y/2, -Size.Z/2)
local RB = Position + Vector3.new(Size.X/2, Size.Y/2, Size.Z/2)
local LB = Position + Vector3.new(-Size.X/2, Size.Y/2, Size.Z/2)

local center = (RF + LF + RB + LB) / 4
local frontVector = (RF - LF).unit
local rightVector = (RB - RF).unit
local upVector = frontVector:Cross(rightVector).unit

local BodyGyroCFrame = CFrame.fromMatrix(center, rightVector, upVector)

local bodyGyro = Instance.new("BodyGyro")
bodyGyro.CFrame = BodyGyroCFrame
bodyGyro.Parent = yourPart

is that what you wanted?

3 Likes

I want to make like ship float in water based on height of each 4 corners in primary part using physics like BodyGyro