Custom Camera Facing Incorrectly

Been working on a custom camera although it only worked while facing forward so i’ve tried using VectorToWorldSpace but it ended up locking the camera behind the character rather than what i intended for it to do

ts:Create(CamPart,TweenInfo.new(1),
	{Position = root.Position + Vector3.new(0,5.5,10)}):Play()

ts:Create(CamPart,TweenInfo.new(1),
	{Position = root.Position + rootOrientation:VectorToWorldSpace(Vector3.new(0,5.5,10))}):Play()

Anyone know a work around for this?

2 Likes

I don’t really get what you’re trying to do here…? mind explaining it some more? (I’m slow i know)

1 Like

What i originally wanted was for the camera to move slightly if the character moved and NOT locked behind the character

1 Like

is this what you’re trying to achieve?

but instead, the camera’s position constantly follows the player’s character also with an offset

1 Like

That’s exactly it yes :sob:
It’s an attempt at recreating silent hill camera system but a bit different

1 Like

Maybe this’ll work…

local CameraPos = root.Position + Vector3.new(0,5.5,10) -- put this out of the loop

local MoveDirection = Humanoid.MoveDirection -- self explanatory 

if MoveDirection.Magnitude > 0.1 then
CameraPos = root.Position + Vector3.new(MoveDirection.X*-10, 5.5, MoveDirection.Z*-10)
end

ts:Create(CamPart,TweenInfo.new(1),
	{Position = CameraPos}):Play()

Another solution is to just make the tween faster, since default Roblox WalkSpeed is measured in Studs Per Second, you need to make the Tween faster depending on the WalkSpeed. For example, it seems that you’re using the default WalkSpeed which is 16 Studs Per Second, and the Camera offset seems to be only 10 Studs in the Z Axis, and because the Tween is 1 second long, the Camera will be behind the Character by 6 Studs when the Character is walking towards the camera.

Or in short,

The Character moves at 16 Studs Per Second and the Camera moves at 10 Studs Per Second. Which causes it to be behind the Character by 6 Studs.

Ngl i did not explain anything right… So what i was doing was moving the camera up and back whenever you faced slightly sideways as such:

Also didn’t notice i reverted to the wrong version which used LookVector (which without for some reason doesn’t do as intended i guess?)

ts:Create(CamPart,TweenInfo.new(1),
	{Position = root.Position + (-root.CFrame.lookVector) + Vector3.new(0,5.5,-10)}):Play()

But whenever you’d go backwards, of course, it would cause the issue i’ve shown previously with the camera trying to face the front of the character rather than behind

Yeah. Like i said, the Character Moves at 16 Studs per Second and the Camera moves at 10 Studs Per Second. So, if the Character moves backwards/towards the camera then the Camera will be Behind the Character by 6 Studs. Try making the Tween faster or the Character Humanoid Speed to 10 or below.

I don’t mean that the camera is futher away from the character i mean it legit will NOT face behind the character

Tried to script something on studio, but ended up getting the same problem. At some point when the Camera is close to the Character, it starts glitching out. Not sure if there’s a way to solve it, guess we’ll just wait till someone gives out an answer.

I think I’ve found a way to kinda fix it by adjusting the offset when the humanoidrootpart and camera are at similar magnitudes, but it doesn’t feel natural and even messes up other elements.

can you show me a video? scripts too if possible… I’ll see what I can do with it (not the entire script, just some parts that I can examine)

So i’ve actually figured it out by doing something similar to what you sent previously:

	local Point_To_CamPart = (Moving_Point.Position - CamPart.Position).Unit
	local Facing_Cam = Point_To_CamPart:Dot(Moving_Point.CFrame.LookVector)

	if Facing_Cam >= 0.5 then
		ts:Create(CamPart,TweenInfo.new(1),
			{Position = root.Position + Vector3.new(Moving_Point.CFrame.LookVector.X * -7, 5.5, Moving_Point.CFrame.LookVector.Z * -7)}):Play()
	end

Although rather than just have it move only when the character is moving, it instead moves if you aren’t facing towards the camera.

Not sure how i didn’t figure that out already, but yet again, i’m not the best with vectors :no_mouth:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.