Is there any way to weld/attach a block to the playercamera, so that as the camera moves around the block stays in the same position on a client’s screen? I’ve attempted this by updating the CFrame of the block if the camera position changes (a lot of stutter there) and I’ve tried using TweenService on the block (see video below.)
Neither method produces the desired results of making it look like the block is “attached” to the screen. Anyone have any tips/things to try? Thanks
You can use BindToRenderStep() and set the priortiy to Enum.RenderPriority.Camera.Value. Here is more info.
local runservice = game:GetService("RunService")
local part = --wherever it is
local function SetToCamera()
part.CFrame = workspace.CurrentCamera.CFrame
end
runservice:BindToRenderStep("Any name you want", Enum.RenderPriority.Camera.Value, SetToCFrame())
Set the CFrame of the part to the camera’s CFrame. If you want like a quint tween, then make it do it every .1 seconds, and have the quint tween take around .2 - .5 seconds.
Updating the CFrame of the part every time the Camera’s CFrame changes works fine for me?
local Camera = workspace.CurrentCamera
local part = Instance.new"Part"
part.CanCollide = false
part.Anchored = true
part.Parent = workspace
local function update()
part.CFrame = Camera.CFrame*CFrame.new(0,0,-5)*CFrame.Angles(math.pi/7,math.pi/9,math.pi/2)
end
Camera:GetPropertyChangedSignal"CFrame":Connect(update)
update()
This works great, thanks I realize now the way I was trying to achieve it earlier (with an infinite while loop which updated the position) was probably not only inefficient but quite ineffective compared to this method. Thank you again
Hey do you know how I can make the part an already existing part instead of a new part? Because every time I set it to that part it says it’s not a valid child of Workspace.