Realistic flight with BodyGyro

Ok so the title is a bit messy, but basically: My game uses BodyVelocity and BodyGyro to make my dragon fly. The turning part looks like this:

local cam = workspace.CurrentCamera
local midpt = cam.ViewportSize/2
local direction = cam:ViewportPointToRay(midpt.X, midpt.Y).Direction
bg.CFrame = CFrame.new(Vector3.new(), direction)

And the finished product like this:
https://gyazo.com/43f15d30ce1f8237d5f6b247a513e7f5

But it looks stiff. Is there a way to add a little tilt when turning (like birds do)?
I tried getting difference between camera and humanoidrootpart orientation and tilt character with this force, but it either started glitching and flopping around itself like crazy or it would tilt relatively to global position.

12 Likes

First of all, that looks amazing!

Well, I’m not entirely sure how to do that; but I remember crazyman32 made a plane system like a decade ago. I think that is the effect you’re looking for, but it uses the mouse to manuever rather than the camera.

local mouse = game:GetService("Players").LocalPlayer:GetMouse()

local bank = ((((mouse.ViewSizeX/2)-mouse.X)/(mouse.ViewSizeX/2))*20)
bank = (bank < -20 and -20 or bank > 20 and 20 or bank)

bg.CFrame = mouse.Hit * CFrame.Angles(0, 0, math.rad(bank))
3 Likes

Thank you!

That’s what I’m aiming for, but my game uses camera instead of mouse and I have trouble calculating difference between HRP orientation and camera orientation.

1 Like

I know it’s been almost a year, and I saw that your game has already been out. How did you achieve the tilting effect? I’m trying to figure it out myself.

those are either BodyGyro or something like BodyAngularVelocity

He said he used Body Gyros. Body gyros are for angular displacement, while BodyAngularVelocity is for making something spin constantly. I’m just stuck on how he was able to do the math on the tilting.

CFrame.Angles maybe or CFrame.RightVector

I’m in a similar predicament - 10/02/2021.

Was the solution to this found?

1 Like

Same here, you found a solution?

2 Likes