Repost in hopes this can get some traction
I’m using a water height sampling module to create a boat that accurately responds to water
The main issue I’m currently facing is the boat ‘drives away’ whenever I multiply the CFrame by the corresponding pitch and roll that I’ve calculated
However, the boat works fine if I don’t multiply it by the angles
There is probably a really simple fix, but I can’t seem to think of anything right now
Below is a segment of my code as well as 2 videos
Any help is appreciated
rs.Heartbeat:Connect(function()
local roll = roll()
local pitch = pitch()
local primPart = script.Parent.PrimaryPart
local p = primPart.Position
local look = primPart.CFrame.LookVector
local boatcoord = (starboard.Position.Y + stern.Position.Y + bow.Position.Y + port.Position.Y)/4
p = Vector3.new(p.X, boatcoord, p.Z)
look = Vector3.new(look.X, 0, look.Z)
local cf = CFrame.new(p, p + look) * CFrame.fromEulerAngles(pitch, 0, 0) * CFrame.fromEulerAngles(0, 0, roll)
script.Parent:PivotTo(cf)
end)
What happens when I remove the code including the angles
I’ve ran into this exact same problem while also working with CFrames and sad to say I think its a bug, I haven’t found a way to get around it nor going to do anything about it so… just kinda sucks.
The weird part about this is I’m using a water sampling module from @. robro786
Maybe it has something to do with the formula I’m using to calculate roll/pitch?!
Just using basic trig
Seriously doubt it has to do anything with the formula though
I doubt it. I went back to confirm that my issue was still going on, and yea it still is.
Suprisingly it only breaks for me when the second CFrame.new()'s Y Value is not zero, shown in the snippet below:
--psuedocode of what i was doing
Part.CFrame = CFrame.new() * CFrame.FrumEulerAngles() * Cframe.new(_,"cannot be 0",_)
If I had to take a wild guess its because something dosent work right when calculating the new CFrame, so it skips to the physics engine to give it an updated position (for some reason) and I only say this because I’ll move the part around, like over hills and ramps, and it will slide down them smoothly even though its still updating only CFrame values.
Just dont spend a lot of time overthinking like me please