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