Tweening camera's rotation not working properly

How can I make the camera keep on following the player during the Rotation tween.
If I set the CFrame of the camera * the rotation then the camera won’t follow so I dont really know how else would I approach this. Please don’t give me any answers that don’t use CFrame or Lerp.

local rightTween = tweenService:Create(camera, TweenInfo.new(0.3, Enum.EasingStyle.Sine, 
Enum.EasingDirection.InOut, 0, false, 0), {CFrame = camera.CFrame * 
CFrame.Angles(0,0,math.rad(25))})

2 Likes

You’ll probably have to use lerp or some other method to transition from a starting orientation to the goal orientation while keeping the position of the camera the same the whole way through.

1 Like

I tried lerp but without success. I am pretty sure that when it comes to lerps or cframe you need a base position to modify the rotation, If I remove

camera.CFrame*CFrame.Angles(0,0,math.rad(25))

and only do

CFrame.Angles(0,0,math.rad(25))

then the cframe’s position will be automatically set to 0,0,0. I really dont know how to approach this.

1 Like

That’s why you use the top method you wrote.

1 Like

I’m thinking the camera position update in the default camera scripts is being overwritten with your script so the position doesn’t update before you change the angle. You’ll probably need to bind your rotational change to the step event and set the priority to just after the camera update priority.

That or manually update the position of the camera during your tween.

1 Like

But the top method won’t work. It will be at the position but if the player moves during the tween the camera wont follow him.

I understand what you mean, could you please give me an example of how I would go for such an approach since I am not familiar with that kind of thing.

Its going to be more complicated then just a one liner. If you RunService | Roblox Creator Documentation you can change the rotation of the camera at priority 201. But the very next step it will change it back, so you’ll need some sort of check to say: if animation is at time x then rotate y degrees so the rotation changes with each step and sync with the animation.

Basic Example:

RunService:BindToRenderStep("camRotater", 201, function()
	local animPercent = myAnimTrack.TimePosition/myAnimTrack.Length
	local rotAmount = animPercent * 25
	camera.CFrame = camera.CFrame * CFrame.Angles(0,0,math.rad(rotAmount))
end)
1 Like

Oh I see, so I can tween it there and then make a tween.Completed:Wait() and after reset the priority.

To be honest, I barely ever use tweens, but I’m not sure how well a tween would work in the renderstep, my example is sort of doing a manual tween. What you’ve said may work, I personally just don’t know.

1 Like

CFrame = CFrame.new(-309.385, 55.054, -845.296) * CFrame.fromOrientation(math.rad(0.881), math.rad(-127.594)

Add fromOrientaion to your Script :slight_smile:

1 Like