Camera tweening transparency issue

Forgive me if I’m not being clear enough, this is the first time in a while I’ve ever needed to ask a question on the devforum.

I’m designing a camera script for my game where it is a simple modified version of the “Follow” camera script. I forked the PlayerModule script, placed it in StarterPlayerScripts, and directly changed the line that is normally used to update the camera (after all math is calculated) as a tween.

This is the way I did it. On line 504 of CameraModule, I noticed it updates the camera of the player directly:

game.Workspace.CurrentCamera.CFrame = newCameraCFrame

To achieve my smooth effect, I changed the line to this:

Tween.tweenset(
			game.Workspace.CurrentCamera,
			newCameraCFrame
			,step,"Sine","InOut","CFrame"
		)

Tween.tweenset is an outside self-made ModuleScript that essentially simplifies the whole tweenservice processing to one line. The format is given as Object, NewValue, Time, EasingStyle, EasingType, Property. For most functions this is essentially simple, but I notice this effect is problematic when in first person.

I think there is something in the TransparencyController module that is causing this effect, so I took a look. The script is kind of complicated for me to understand, so I tried to look up some solutions on the devforum-- hardly any gives me an understanding. I also tried to trace my steps back on the newCameraCFrame script, but it goes through so many other values that I get a migraine. I believe TransparencyController checks to see how far the camera currently is from the player, which is what the smooth tweening affects. I still want the same tweening effect in first person (although I can remove it somehow if I have to). I’m thinking of getting the value of the player’s current zoom to affect the transparency. What value do I grasp to port to the TransparencyController module, so that it doesn’t depend on the distance of the player but instead how close the player zooms in?

If there is a better solution to fix the transparency issue, I’m open to ideas.

1 Like

You could try changing this section of the TransparencyController module to increase the distance at which it will un-transparency itself:

local distance = (currentCamera.Focus.p - currentCamera.CoordinateFrame.p).magnitude
			transparency = (distance<2) and (1.0-(distance-0.5)/1.5) or 0
                  --change distance<2 to distance<5 or something
			if transparency < 0.5 then
				transparency = 0
			end

However this might be kinda weird, and kinda bypasses the main problem

The main problem is likely that youre not properly setting the camera focus, the point from which the distance is calculated

The default camera basically just sets the focus to hrp.Position+Vector3.new(0,1,0) I think, so Id try that first

1 Like