https://gyazo.com/37e492bafab1a5ce876e2160bf5d22ca
So I’m making an inventory system, and I’m currently cloning the player character and placing it inside the viewport frame (I do this using RenderStepped function. This works, more or less. But it drops massive frames. Any ideas? Cause I’d like to make a real time avatar display window. Is there a more performant way of achieving this?
game:GetService("RunService").RenderStepped:Connect(function()
local characterPreviewWindow = backdrop:WaitForChild("CharacterPreview"):WaitForChild("ViewportFrame")
local cam = Instance.new("Camera")
characterPreviewWindow:ClearAllChildren()
cam.FieldOfView = 50
cam.CameraType = 'Scriptable'
characterPreviewWindow.CurrentCamera = cam
local newRig = CloneMe(game.Players.LocalPlayer.Character)
newRig.Parent = characterPreviewWindow
cam.Parent = newRig
cam.CFrame = newRig.PrimaryPart.CFrame * CFrame.new(0, 0, -10)
cam.CFrame = cam.CFrame * CFrame.Angles(0, math.rad(180), 0)
end)
SelDraken
(SelDraken)
December 5, 2023, 4:05am
#2
Don’t do this in a RenderStepped
There is no need for it to happen every frame.
Once you set it up, it remains until you :Destroy it
Yea but it will just be a static object. As far as I know, the object has to exist inside the viewport frame. Which is why I constantly recreate it.
SelDraken
(SelDraken)
December 5, 2023, 4:06am
#4
If it is just the rotation you need, you can put that in a repeating loop
like a while or even the render step, but only the CFrame part on the camera.
1 Like
SelDraken
(SelDraken)
December 5, 2023, 4:07am
#5
Create it once, then use a loop to move the cameras CFrame
I need to track the avatars animation/movement changes. Changing the camera angle doesn’t do anything for my purposes.
SelDraken
(SelDraken)
December 5, 2023, 4:10am
#7
I was saying that, because of this line of code, it looks like you are rotating the avatar.
You can play animations in viewport frames, its sort of the same as you play an animation on the player’s character.
But regardless of what you are wanting to move or track or whatever, you do not need to recreate the avatar in the viewportframe each frame.
Just create it once, then manipulate it by moving the camera, or playing an animation, etc…
1 Like
Ah ok cool, last I used viewport frames I don’t think any scripts were possible.
1 Like
system
(system)
Closed
December 19, 2023, 4:12am
#9
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.