So, I want to launch player’s camera downwards whenever they jump.
...
humanoid.Jumping:Connect(function(active)
if not active then return end
local oldCFrame = camera.CFrame
local tween = TweenService:Create(camera,
TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{
CFrame = oldCFrame
}
)
tween.Completed:Once(function(pbs)
tween:Destroy()
end)
camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(-30), 0, 0)
tween:Play()
end)
The issue is the camera is being frozen in place while it is tweening.
Is there any way to avoid that?
2 Likes
MrKlocek2
(MrKlocek)
August 8, 2023, 7:51am
2
Try change camera type to scriptable
It already is. I would not be able to change the CFrame if it wasn’t Scriptable.
MrKlocek2
(MrKlocek)
August 8, 2023, 7:54am
4
Did the humanoid.Jumping fire once when haracter jump?
It does. The camera is being yeeted downwards. The problem is it is remaining in the same spot.
MrKlocek2
(MrKlocek)
August 8, 2023, 8:00am
6
run it without this line
camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(-30), 0, 0)
It will not work then. The camera will just freeze in place for 0.5 seconds.
This line is the one that turns the camera downwards.
this might help you
Okay, hopefully I’ve understood what you wanted to correctly but I think I have a solution for this.
First I created a camera animation for a ‘fake camera part’ (like you described) to simulate recoil or whatever camera effect.
[image]
Next I just created a script that cframes the camera to the changed orientation of the fake camera part on render step. The core part of the code that you need to do this is shown below.
local prevRot = CFrame.new()
function updateCamera()
local prevRotX, p…
it is essentially animating a part and setting the rotation of that part to the camera each frame
That post is not about Tweening.
Mystxry12
(Mystxry)
August 8, 2023, 8:14am
10
Use Springs, create one named LandingSpring and call LandingSpring:Impulse(Vector3.new(1, 0, 0)) when jumping. Then inside the RenderStepped just do:
local landingVelocity = LandingSpring.Position
Camera.CFrame *= CFrame.new(landingVelocity)
What is a Spring and where would I create it?
MrKlocek2
(MrKlocek)
August 8, 2023, 8:22am
12
Look like oldCFrame is same as camera.CFrame so nothing changes
(or changes are to small to see)
That’s… the point of oldCFrame…
oldCFrame is supposed to be the same as camera.CFrame in order to return to the initial position.
MrKlocek2
(MrKlocek)
August 8, 2023, 8:40am
14
There is no wait or anything so old cframe and camera.cframe are same that why there is no movment bc tween dont need to move it bc its alredy at old cframe
This is why I am :Playing the tween after I set the new camera CFrame.
MrKlocek2
(MrKlocek)
August 8, 2023, 8:48am
16
But start of tween is not updated and is still same as oldCFrame
humanoid.Jumping:Connect(function(active)
if not active then return end
local oldCFrame = camera.CFrame
camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(-30), 0, 0)
local tween = TweenService:Create(camera,
TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{
CFrame = oldCFrame
}
)
tween.Completed:Once(function(pbs)
tween:Destroy()
end)
tween:Play()
end)
Mystxry12
(Mystxry)
August 8, 2023, 8:52am
17
Here’s the module and the docs
AlternativeOrNot:
where would I create it?
Outside the RenderStepped where it’s accessible
abrah_m
(abe)
August 8, 2023, 11:20am
18
Don’t use tween service. The reason this probably isn’t working is because tween service will constantly apply the rotation math to the old camera position.
I would try using a loop and slowly rotate the camera bit by bit while updating the camera. Something like this:
task.spawn()
for i = 1, 30 do
camera.CFrame = camera.CFrame * CFrame.Angles(math.rad(-1), 0, 0)
task.wait()
end
end
``
I’m not 100% sure what is going on here in your problem though… if this isn’t what you’re looking for, you may want to send some sort of visual.