Hello, I have my characters camera and i want to make the camera go to another Vector3 value but i want there to be a transition. How would i do this?
You will first need to set the Camera Type to Enum.CameraType.Scriptable and then you will need to use TweenService to tween your camera to your required Position, and while creating the Tween you can set your Easing Style, time etc. Then you just Play the Tween.
i need my camera scriptable because its for a 3rd person camera that is locked and when the player presses e or q then the camera shifts to the other side of them
Sorry my bad, I meant Enum.CameraType.Scriptable.
TweenService is probably the easiest way to do it.
local camera = workspace.CurrentCamera
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear) -- 1 is time; you can change EasingStyle if you want
tweenService:Create(camera, tweenInfo, {CFrame = CFrame.new(--[[Vector3 to go to]])}):Play()
And also set camera type to Scriptable like @WaterJamesPlough said.
Im kind of stuck with the animation because i either get the error:
or:
My settings for the camera
UserInputService.InputChanged:Connect(function(inputObject, busy)
if busy then
return
end
if inputObject.UserInputType.Name == "MouseMovement" then
local delta = inputObject.Delta
xAng = math.clamp(xAng - delta.y*sensitivity*math.pi/180, minAngle*math.pi/180, maxAngle*math.pi/180)
yAng = (yAng - delta.x*sensitivity*math.pi/180)%(2*math.pi)
end
end)
RunService.RenderStepped:Connect(function()
local character = PlayerService.LocalPlayer.Character
if not character then
return
end
local rootPart = character:FindFirstChild("HumanoidRootPart")
if not rootPart then
return
end
if lockMouse then UserInputService.MouseBehavior = "LockCenter" else end
local cameraCFrame = CFrame.new(0, 1.5, 0)
*CFrame.Angles(0, yAng, 0)
*CFrame.Angles(xAng, 0, 0)
*CFrame.new(offset)
+ rootPart.CFrame.p
currentCamera.CFrame = cameraCFrame
Which line is line 56? I can’t tell very well but my best guess is offset
is a CFrame. It’s hard to tell though without the line numbers.
You could try tweening a part’s CFrame.
For the player’s camera, you can make it so everytime the part’s Position is changed, the camera’s point of interest changes to the current part’s position.
I tried this myself in a place of mine, and the result is pretty smooth.
local partProperties = {}
partProperties.CFrame = CFrame.new(0, 0, 0)
local Tween = tweenservice:Create(campart,TweeningInformation,partProperties)
Tween:Play()
campart:GetPropertyChangedSignal("CFrame"):connect(function()
Camera.CFrame = campart.CFrame
end)
Or you can, y’know, tween the Camera’s Subject, that will do the same.