There is a problem with CFrame

How do you think to make the camera stay in the resulting CFrame when the player is not moving? If anything, the player can rotate the camera freely, but the camera must keep the CFrame received when the player stopped. Who doesn’t understand, it should look like in SCP: Containment Breach.

RNS.RenderStepped:Connect(function()
	local velocity = math.round(Vector3.new(HRP.AssemblyLinearVelocity.X, 0, HRP.AssemblyLinearVelocity.Z).Magnitude)

	if velocity > 2 then
		camera.CFrame *= CFrame.new(0, GetCurve(verFrequency, verIntensity) * velocity / defWalkSpeed, 0) * CFrame.Angles(0, 0, math.rad(GetCurve(rotFrequency, rotIntensity) * velocity / defWalkSpeed))
		InitialVelocity = velocity
	elseif velocity <= 0  then
		camera.CFrame = ???
	end
end)

Here’s a gameplay: https://www.youtube.com/watch?v=OKKkS7HyWbI

2 Likes

So I’m guessing the camera’s CameraType is Scriptable, right?

Also I’ve watched thr demo video and it just looks like a first person camera. Are you just trying to achieve a first person view?

1 Like

No, this is a camera with a normal type: it’s just that when I assign it a CFrame, it goes to hell.

2 Likes

No, the camera is working well, I just have to do it.

1 Like

Sorry I’m really confused… But just to make sure, Is your goal to achieve a first person camera?

1 Like

You don’t understand. Everything works great. However, I need to achieve that when the player stops, the camera remains in the same position as it was while walking, while the player can move it. The video at the end especially shows this.

1 Like

Ohh, thanks for the explanation.

In that case, if the velocity is 0, try setting the CFrame to itself, so that way it stops moving.

1 Like

I don’t really understand how to do this. Are you talking about the camera? If you’re talking about Camera.CFrame = Camera.CFrame, it won’t work.

1 Like

Yeah, in that case I don’t know what to say…

Sorry, but I can’t figure it out

1 Like

What can’t you understand? It is necessary to make sure that the camera remains in the same CFrame, but the player could move the camera, that is, the Z orientation remained at the same value (there was the same tilt of the camera when there was the last movement), but the player could rotate the camera freely.

2 Likes

Yeah, I understand the goal, I just don’t really know how to go about it.

Sorry I couldn’t be of any help.

1 Like

I’d suggest making the Character platformstand by setting PlatformStand in the Humanoid of the character to true.
That makes the player unable to move but still free to look around and rotate however they want to.

Sorry, but this is not the right solution. Here only the player will stop and be able to rotate the camera. I need to make the camera partially freeze in the last orientation (which is obtained when walking), but the player could rotate the camera. The problem is that the camera changes the CFrame to a regular CFrame.

You could store the last value which has changed camera’s CFrame into one variable and use it.

I tried this option, to be honest, it didn’t work. The camera freezes and that’s it!

How are you exactly handling camera freeze?

Well, I tried your version. Here it is:

RNS.RenderStepped:Connect(function() 
	local velocity = math.round(Vector3.new(HRP.AssemblyLinearVelocity.X, 0, HRP.AssemblyLinearVelocity.Z).Magnitude) 
	if velocity > 0 then 
		camera.CFrame *= CFrame.new(0, GetCurve(verFrequency, verIntensity) * velocity / defWalkSpeed, 0) * CFrame.Angles(0, 0, math.rad(GetCurve(rotFrequency, rotIntensity) * velocity / defWalkSpeed))
		CFrame2 = camera.CFrame * CFrame.new(0, GetCurve(verFrequency, verIntensity) * velocity / defWalkSpeed, 0) * CFrame.Angles(0, 0, math.rad(GetCurve(rotFrequency, rotIntensity) * velocity / defWalkSpeed))
	else
		camera.CFrame = CFrame2
	end
end)

And before, there was no line with the change of CFrame to CFrame2. The camera does not freeze without this line!

have u tried something like this? Instead of setting the cameraCFrame, you multiply it like before

local lastCFrame

RNS.RenderStepped:Connect(function()
	local velocity = math.round(Vector3.new(HRP.AssemblyLinearVelocity.X, 0, HRP.AssemblyLinearVelocity.Z).Magnitude)

	if velocity > 2 then
		lastCFrame = CFrame.new(0, GetCurve(verFrequency, verIntensity) * velocity / defWalkSpeed, 0) * CFrame.Angles(0, 0, math.rad(GetCurve(rotFrequency, rotIntensity) * velocity / defWalkSpeed))
		camera.CFrame *= lastCFrame
		InitialVelocity = velocity
	elseif velocity <= 0 then
		if lastCFrame then
			camera.CFrame *= lastCFrame
		end
	end
end)

After using your code, the camera will still not remain in the CFrame that I got from walking. Camera’s CFrame becomes a CFrame, as if it were without the influence of Camera Bobbing.

The problem is that it is multiplied by one, so to speak, that is, every time RenderStepped is performed, the camera multiplies its CFrame by the resulting CFrame from the formula, and each change is quite small.
And I also noticed that the camera’s CFrame seems to start over, which may now be the main problem that needs to be solved. Therefore, it is necessary to use something else, but now more related to this problem.