Basically, I am trying to make a boat roll on the waves of an ocean. One method that I think will work the best is by having four ray casts on each side of the boat. Bow, Stern, Starboard, and Portside. I already have the math figured out for the orientation and position of the boat, but the problem I have is that the raycasts aren’t actually picking up waves and are instead picking up the original position of the ocean plane.
(The ocean is a meshpart that has its bones updated to create the “waves”)
The local script is in the player since the waves are also generated locally.
local RunService = game:GetService("RunService") local Stern = game.Workspace.Boat.Stern local Bow = game.Workspace.Boat.Bow local wavelist = game.Workspace.Ocean.Oceans:GetDescendants() RunService.Heartbeat:Connect(function(step) local sternray = Ray.new(Stern.Position, Vector3.new(0, -100, 0)) local bowray = Ray.new(Bow.Position, Vector3.new(0, -100, 0)) local wavefound1, position1 = workspace:FindPartOnRayWithWhitelist(sternray, wavelist) local wavefound2, position2 = workspace:FindPartOnRayWithWhitelist(bowray, wavelist) -- Code shows the position of the raycast as a part, all come back as the original plane position before the waves were ever generated. if wavefound1 then local Newpart = Instance.new("Part") Newpart.Parent = game.Workspace Newpart.Anchored = true Newpart.Position = position1 wait(0.1) Newpart:Destroy() end end)
If you have any solutions or ideas to solve this problem that would be awesome! Thank you!