Hello! Recently, I got an issue that keeps bugging me.
I’ve been attempting to animate the turning of a jet ski, but with the method I used, displacement keeps happening within the welds, and in time, it leads to ridiculous sights (The player starts sitting on the air, behind the ski, alongside some water splashing effects).
Until now, I’ve used
local RX,RY,RZ = MeshPart.CFrame:ToOrientation()
To get the individual X,Y,Z in radians, then
script.Parent.Parent.MeshPart.Orientation = Vector3.new(math.deg(RX),math.deg(RY),-20)
To only set the Z orientation value in a while wait() do loop
(Yes I did add the line that separates the CFrame coordinates into X,Y,Z in the loop.)
But the issue is that the model is moved by a BodyGyro at relatively fast speeds, which again, results to displacements and issues in time.
I did try to use a function for this action, too
DSeat.Changed:Connect(function() end)
But it resulted in push backs with the position, as the function took it’s time when checking for the position.
I did try to make 2 different scripts, one with the function, and the other one with a continuous loop which was supposed to save the real time coordinates into separated values, but it showed the same push back that only using the function did.
This here is the full current code, with the displacements.
local DSeat = script.Parent
DSeat.Changed:Connect(function()
local RX,RY,RZ = script.Parent.Parent.MeshPart.CFrame:ToOrientation()
if DSeat.Steer == 1 then
script.Parent.Parent.MeshPart.Orientation = Vector3.new(math.deg(RX),math.deg(RY),-20)
end
if DSeat.Steer == -1 then
script.Parent.Parent.MeshPart.Orientation = Vector3.new(math.deg(RX),math.deg(RY),20)
end
if DSeat.Steer == 0 then
script.Parent.Parent.MeshPart.Orientation = Vector3.new(math.deg(RX),math.deg(RY),0)
end
end)
And here would be the code which causes push backs, but doesn’t create that many displacements in time.
local DSeat = script.Parent
while wait() do
local RX,RY,RZ = script.Parent.Parent.MeshPart.CFrame:ToOrientation()
if DSeat.Steer == 1 then
script.Parent.Parent.MeshPart.Orientation = Vector3.new(math.deg(RX),math.deg(RY),-20)
end
if DSeat.Steer == -1 then
script.Parent.Parent.MeshPart.Orientation = Vector3.new(math.deg(RX),math.deg(RY),20)
end
if DSeat.Steer == 0 then
script.Parent.Parent.MeshPart.Orientation = Vector3.new(math.deg(RX),math.deg(RY),0)
end
end)
I consider displacements to be inevitable in this situation. Of course, there is a few milliseconds of delay between reading the position and applying it, and I’m judging that the weld cannot react to such tiny changes so fast.
So, for my question, is there any way to only change 1 axis of the rotation, without setting the other axis to their previous position, but only changing one of them, like I’ve seen recommended countless times.
Or, maybe there is another way I could do this that I didn’t think of…
Thank you for your time! Looking forward to responses.