How to make camera alway show infront of you no matter where you are

how to make camera alway show infront of you no matter where you are , i was trying to make a cutscene beatdown like this video but when i make the animation + camera in moon animator the animation + camera alway show at the location where u make the animation and camera

https://www.youtube.com/watch?v=MYBH1zlUDUc&ab_channel=TheBizarreChannel

You can do this pretty easily. Set the camera type to scriptable and then use the CFrame.lookAt constructor.

Sorry I can’t go more in-depth. I’m kinda sleepy right now. If this topic isn’t solved by someone else tomorrow then I will add a more in-depth response.

3 Likes

Btw how to use CFrame look at ,

1 Like

Alright, like promised I’ll answer your question since it hasn’t been solved.

I ended up creating a tutorial for how to animate the camera. You can view it here:

Also, CFrame.lookAt is pretty simple. You simply need an origin, where the position of the CFrame is, and a lookAt, a positional Vector3 | Roblox Creator Documentation that is the position that you want to look at.

CFrame.new(position, lookAtPosition)
1 Like

how to make it when player use a move the cutscene play

image

Can you show me the function call in the local script your using?








local function animateCamera(rootPart, camera, cameraScenes)
	local initialCameraFrame = rootPart.CFrame:ToObjectSpace(camera.CFrame)
	local initialCameraType = camera.CameraType
	camera.CameraType = Enum.CameraType.Scriptable

	for _, cameraScene in pairs(cameraScenes) do
		camera.CFrame = rootPart.CFrame:ToWorldSpace(cameraScene.InitialOffset)

		local cameraTween = TweenService:Create(camera, cameraScene.TweenInfo, {CFrame = rootPart.CFrame:ToWorldSpace(cameraScene.EndOffset)})
		cameraTween:Play() 
		cameraTween.Completed:Wait()
		cameraTween:Destroy() 

		task.wait(cameraScene.Delay) 
	end

	camera.CFrame = rootPart.CFrame:ToWorldSpace(initialCameraFrame) 
	camera.CameraType = initialCameraType  
end

animateCamera(rootPart, camera, cameraScenes)

and this is my script

local TweenService = game:GetService("TweenService") 

local rootPart = script.Parent.PrimaryPart
local camera = workspace.CurrentCamera 

local cameraScenes = {
	{
		InitialOffset = CFrame.new(-1.84375, 2.28120041, -3.72264099, -0.896119118, 0.246898666, -0.368797451, 0, 0.830973744, 0.556311667, 0.443813562, 0.498521507, -0.744651496),
		EndOffset = CFrame.new(3.859375, 2.22237015, -5.30947876, -0.833500385, -0.188059226, 0.519529402, -1.49011594e-08, 0.940292656, 0.340367049, -0.552518845, 0.283696055, -0.783734381),
		TweenInfo = TweenInfo.new(),
		Delay = 1
	},
	{
		InitialOffset = CFrame.new(0.22265625, 2.32366562, -3.40678406, -0.999632716, -0.0136118429, 0.0234374292, 0, 0.864740789, 0.502218664, -0.0271034185, 0.502034187, -0.864423096),
		EndOffset = CFrame.new(0.21875, 3.28287125, -5.10414124, -0.999838889, 0.0088400282, -0.0156248957, 0, 0.870358527, 0.492418826, 0.017952254, 0.492339492, -0.870218217),
		TweenInfo = TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),
		Delay = 5
	},
	{
		InitialOffset = CFrame.new(2.56640625, 1.81679153, 1.74195862, 0.913751185, 0.00280294032, 0.406264722, -2.32830644e-10, 0.999976337, -0.00689913006, -0.406274408, 0.00630408805, 0.913729429),
		EndOffset = CFrame.new(1.765625, 1.5592804, 1.74745178, 0.919699013, 0.0395444073, 0.390627652, 0, 0.994915009, -0.10071823, -0.39262411, 0.0926304534, 0.915022373),
		TweenInfo = TweenInfo.new(5, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut),
		Delay = 1
	}
}

local function animateCamera(rootPart, camera, cameraScenes)
	local initialCameraFrame = rootPart.CFrame:ToObjectSpace(camera.CFrame)
	local initialCameraType = camera.CameraType
	camera.CameraType = Enum.CameraType.Scriptable

	for _, cameraScene in pairs(cameraScenes) do
		camera.CFrame = rootPart.CFrame:ToWorldSpace(cameraScene.InitialOffset)

		local cameraTween = TweenService:Create(camera, cameraScene.TweenInfo, {CFrame = rootPart.CFrame:ToWorldSpace(cameraScene.EndOffset)}) 
		cameraTween:Play() 
		cameraTween.Completed:Wait() 
		cameraTween:Destroy() 

		task.wait(cameraScene.Delay) 
	end

	camera.CFrame = rootPart.CFrame:ToWorldSpace(initialCameraFrame) 
	camera.CameraType = initialCameraType 
end

animateCamera(rootPart, camera, cameraScenes)

I don’t see anything that different. It’s strange, because it worked for me without any errors. While testing in studio, can you click on the error that appears in the output and then show me the line it takes you too?

umm the camera look at the dummy idk why this is the video

https://gyazo.com/4beb1cda7f2ad3acc59dba27e590f0fa

Did you change the root part to the HumanoidRootPart of the character you want to play this animation on?

how to change to character?

local Player = game:GetService("Player")
local char = Player.Character

local rootPart = char.HumanoidRootPart

like this? and can i add more angle? yo its really work

https://gyazo.com/a166ce1984faffe0d5297e6619405099

I don’t think you understand code enough. However, I will still try to help.

First off, that’s not how you get the player in a local script. game:GetService("Player") is not an actual service. However, you can get the Players | Roblox Creator Documentation service. It has a property that returns the local player.

You can use it like this:

local player = game:GetService("Players").LocalPlayer

local rootPart = (player.Character or player.CharacterAdded:Wait()):WaitForChild("HumanoidRootPart")

You can add as many angles as you want. I highly recommend you read the tutorial I provided, as it will detail how it works and how you can add more.

1 Like

how to make camera looking at enemy

This is my script

local Hitbox = script.Hitbox:Clone()
	Hitbox.Parent = game.Workspace
	Hitbox.CFrame = char.PrimaryPart.CFrame * CFrame.new(0,0,Hitbox.Size.Z/2 * -1)
	Debris:AddItem(Hitbox,.8)
	local Connection 
	Connection = Hitbox.Touched:Connect(function(hitpart)	
		if not hitpart:IsDescendantOf(char) then
			if hitpart.Parent:FindFirstChild("Humanoid") then
				local enemy = hitpart.Parent

how about this? how to solve this?

You’ll have to fire a remote the client and have it set the rootPart and run the function