Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

my idea of gui swaying is not very reliable how do i fix the bounciness?

Asked by
Puppynniko 1059 Moderation Voter
2 years ago

the first idea i had was to make a stationary point/attachment infront of the head and the gui would be updated constantly in a loop to that position. i know its a wacky solution but im not good with reading math head bob and yes i did took it from someone

001-- CONSTANTS --
002-- Camera position offset from HumanoidRootPart:
003local OFFSET = Vector3.new(0, 3, 0)
004local RAY_DISTANCE = 100
005-- Mouse sensitivity multiplier
006local SENSITIVITY = 0.006
007-- Verticle angle limits (how far you can look up and down):
008local UPPER_ANGLE_LIMIT = math.rad(85)
009local LOWER_ANGLE_LIMIT = math.rad(-85)
010-- How many bobs per second horizontally and vertically:
011local BOB_FREQUENCY_Y = 4
012local BOB_FREQUENCY_X = 2
013 
014-- How intense the horizontal and vertical bobs are:
015local BOB_AMPLITUDE_X = 0.6
View all 112 lines...

and heres my prototype ik its very ugly

01local runS = game:GetService("RunService")
02local Cam = workspace.CurrentCamera
03local LocalPlayer = game:GetService("Players").LocalPlayer.Character:WaitForChild("Head"):WaitForChild("FaceFrontAttachment")
04local Frame = game:GetService("Players").LocalPlayer.PlayerGui.ScreenGui.Frame
05local function SetupAttachment(Char)
06    local A = Instance.new("Attachment")
07    A.Parent = Char:WaitForChild("HumanoidRootPart")
08    A.WorldPosition = Char:WaitForChild("Head").Position + Char:WaitForChild("Head").CFrame.LookVector
09    return A
10end
11local Attachment = SetupAttachment(game:GetService("Players").LocalPlayer.Character)
12runS.Stepped:Connect(function()
13    Frame.Position = UDim2.fromOffset(Cam:WorldToViewportPoint(Attachment.WorldPosition).X,Cam:WorldToViewportPoint(Attachment.WorldPosition).Y)
14end)
0
Why remake the code when you can just mess around with the variables to find the perfect solution? greatneil80 2647 — 2y
0
it has quite the problems since its in world position and it does not move with the camera although i have already found another solution Puppynniko 1059 — 2y

Answer this question