Do I have to built a connection with Camera to work with it?

Do I have to built a connection with Camera to work with it?

``Imprtant before you listen anything: I just want you to understand my problem and give me an explanation - if you have a lot of problems to understand what I mean then please ask me and I will explain you better I mean - anyways I hope you can understand what I mean.`

So what do I want achieve?
I seriously dont want achieve anything I just want say that I cant understand the structure of Camera system. So the ,(look at the script and the picutre), problem I do have is that I cant understand how he works with the Camera. I can understand the whole script but I cant understand the connection between Camera and Tween. It looks like he never use Camera

I will now try to explain better and deeper I hope you can understand what I mean with “connection between Camera and Tween”.

So a Tween has 3 things, like that: TweenService:Create(Object, Info, Property)

but if you look at the picture I have sent here then you may asking urself: I can see a tween but I cant see any connections between the tween and Object. Like there is a creation between a Humanoid and Camera but why doesnt he work with the " local CurrentCamera = workspace.CurrentCamera". So the Object of the Tween should be “CurrentCamera” like:

local TweenCameraOffset = TweenService:Create(CurrentCamera, CameraTweenInfo, CameraOffset)

but it is

local TweenCameraOffset = TweenService:Create(Humanoid, CameraTweenInfo, CameraOffset)

what I cant understand cuz it shows me that there is no connection.

but where is the connection to the Camera?
–Can you follow me here what I am saying to you. I cant see a connection to the Humanoid and the Camera.

So if I have to work with the Camera I need to build a “Connection” or am I wrong?. The TweenameraOffset

The next Question is:
Do I have to build a connection in my tweens with Camera or is it enough to write at the beginning of the script.

local CurrentCamera = workspace.CurrentCamera

local ECS = {}

--- Services ---

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local UserGameSettings = UserSettings():GetService("UserGameSettings")
local TweenService = game:GetService("TweenService")

--- Constants ---

local Player = Players.LocalPlayer
local CurrentCamera = workspace.CurrentCamera
local DefaultFieldOfView = 70
local CameraTweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut) --Feel free to edit your desired tween style or adding more styles as you like
local MouseSensitivity = UserInputService.MouseDeltaSensitivity

--- States ---

local isAligned = false --To define the state when the character facing forward as the camera angle
local isSteppedIn = false --To define the state when moveing camera without right-clicking

--- Functions ---

function ECS:MouseIcon(Status) --To toggle mouse icon

	UserInputService.MouseIconEnabled = Status

end

function ECS:MouseLock(Status) --To toggle moving-camera-without-right-clicking mode as well as locking mouse at center of screen

	isSteppedIn = Status

end

function ECS:Alignment(Status) --To toggle character alignment to the camera

	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")

	Humanoid.AutoRotate = not Status
	isAligned = Status

end

function ECS:CameraMode(Mode) --To toggle different camera modes

	if Mode == "Aim" then

		local Character = Player.Character
		local Humanoid = Character:WaitForChild("Humanoid")

		local FieldOfView = {FieldOfView = DefaultFieldOfView - 20} --Edit the amount of FOV that you would like to substract to achieve zoom effect
		local CameraOffset = {CameraOffset = Vector3.new(2, 1, 0)} --Edit your desired camera offset

		local TweenFieldOfView = TweenService:Create(CurrentCamera, CameraTweenInfo, FieldOfView)
		local TweenCameraOffset = TweenService:Create(Humanoid, CameraTweenInfo, CameraOffset)

		TweenFieldOfView:Play()
		TweenCameraOffset:Play()

		UserInputService.MouseDeltaSensitivity = MouseSensitivity / 2 --Edit the amount you would like to lower the mouse sensitivity

	end

then I dont need to make a connection with tween and camera?

Like the complete script will be about Camera? If not then you or I didnt understand each other

I didn’t understand you, sorry.
What do you mean by connection?

can you read the whole post again and try to understand what I mean?

I seriously tried everything above to explain. English is my foreign language.

If you still didnt understand that above I will try to explain again

Are you wanting to know if you have properly referenced the camera and the humanoid?

Edit: Go to the second section, I just realized this isn’t what you’re asking

I believe you want something like this:

The BindToRenderStep function binds a custom function to be called at a specific time during the render step. There are three main arguments for BindToRenderStep: name , priority , and what function to call.

I’d recommend either using this function or RenderStepped to update the camera. Something to note for BindToRenderStep is that you’ll want to set the priority to the correct amount. The Wiki recommends a priority of 200 for camera controls.

You can look at RenderPriority Enum page for more examples of priorities.


By connection, you also might mean how the camera is aligned with the character/humanoid. This is done with the CameraSubject. When the CameraSubject is set to a humanoid, and the Camera.CameraType is set to one of a few types, the camera follows the character. The code you provided tweens the Humanoid.CameraOffest, which then affects the Camera’s position through the Camera.CameraSubject property.

1 Like

Humanoids have a property called “CameraOffset”, which offsets the camera position. That is why the tween is being run on the Humanoid instead of the Camera.

The first property here is what is being tweened:
image

1 Like

Okey but just the variable is called: CameraOffset.

It should be then:

local TweenCameraOffset = TweenService:Create(Humanoid.CameraOffset, CameraTweenInfo, CameraOffset)

I cant see any connection to Humanoid

The first parameter is the object to be tweened. In this case it’s the humanoid. The next is the TweenInfo, and the one after that is the goal table. The goal table is formatted like this:

{
	propertyName = value;
	secondPropertyName = value;
	-- etc.
}

So that means, in this case, the TweenService:Create call would be formatted like this:

local Humanoid -- set to the humanoid
local CameraTweenInfo -- set to the tween info
local TweenCameraOffset = TweenService:Create(Humanoid, CameraTweenInfo, {CameraOffset = Vector3.new(2, 1, 0)})

The reason that inputting Humanoid.CameraOffset can’t work is that Humanoid.CameraOffset is a Vector3 property, so there isn’t a way for the function to get the Humanoid that it’s trying to affect.

You can also add more than one property into the goal table to tween more than one property at once. For example:

local part = Instance.new("Part")
part.Parent = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1.0, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true) -- normal tween info but it reverses after finishing
local tween = TweenService:Create(part, tweenInfo, {
	Size = Vector3.new(5,5,5);
	Color = Color3.new(0,0,0);
})
while true do
	tween:Play()
	tween.Completed:Wait()
end

(you can either enter this code into the command bar or put it inside a script to try it out)


You can read about the parameters of TweenService:Create here:

I think now I understood.

If I do a TweenService with the Humanoid and the goal is a Vetor3 property then it will affect the camera?

If that isnt true: then the Humanoid might not have a Position cuz its not the HumanoidRootPart