How would I go on about making this? [Camera Effect]

Hello!

So, I was making a game full of NPCs, and I of course wanted to have a good NPC-Dialogue system.

I made my own dialogue system, GUI and everything else works fine in that area, but I also want a special camera effect while talking to NPCs…

So, here is the general idea behind this “Camera Effect”.

  1. I come up to the NPC, trying to trigger the dialogue trigger.

  2. When the Dialogue trigger is triggered, I want my camera to look at (Without changing its position and without changing its CameraSubject) the NPC and I want the camera to slightly zoom in. (I already know how I would go on about smoothly zooming in using Camera’s Field of View.)
    But how would I go on about making the camera look at the NPC without moving the Camera’s Position? (Basically I want the camera to smoothly change its orientation (I want it to look directly at the NPC) but I don’t want to change the camera’s position.)

    The result should look something like this:

Any help appreciated!

2 Likes

You could try CurrentCamera.focus when you start and set back the focus on the character’s humanoid but this is an hacky solution

1 Like

I’m not too sure, but I think the best way to do this would just be using a camera part, and setting the CurrentCamera.CFrame to the part.CFrame

1 Like

Alright, so after some digging around I eventually found out how I would do this,…

local IsTalking = false
local Camera = game.Workspace.CurrentCamera
NPC_HumanoidRootPart = ...

...
RunService.RenderStepped:Connect(function() -- On Every Frame
	if IsTalking and NPC_HumanoidRootPart then -- Checks if the player is talking to the NPC and if NPC_HumanoidRootPart exists.
		Camera.CameraType = Enum.CameraType.Scriptable -- When the camera is set to scriptable, it doesn't move, and the player can't control it anymore unless you script it so the player can control it.
		Camera.CFrame = Camera.CFrame:Lerp(CFrame.lookAt(Camera.CFrame.Position, NPC_HumanoidRootPart.Position + Vector3.new(0,0,0)), 0.07)
		TweenService:Create(Camera, TweenInfo.new(2), {FieldOfView = 45}):Play() -- Zooms in the camera.
	end
end)

I don’t know if this is a good way to do this, but it does the job.

What do the . . . do???

1 Like

That’s where you would put your NPC’s Humanoid Root Part…

For example, if your NPC was in workspace, under a Folder named NPCs you would put: NPC_HumanoidRootPart = game.workspace.NPCs. (NPC's name) .HumanoidRootPart

If you are talking about the … above the RunService.RenderStepped:Connect(function(), that’s where I had additional code. Since I have multiple NPCs, and I have only one Local Script in StarterGUI, when the Trigger is activated, there is a special RemoteEvent which sends me that NPCs Humanoid Root Part to that Local Script in the StarterGUI (PlayerGUI), so I don’t have to search for the NPC’s Root Part manually.

Oh, ok I see that now. Thanks.