Help on creating a dynamic ocean using Beams

Hi. I recently played a game called Fishing Simulator, which contains amazing waves and ocean physics. After searching everywhere about this, I figured out this effect was created using beams, so I set out to create an algorithm to do this. It is just nodes ordered in a grid, and I attached beams between each of them. It created this when moving the nodes around using the move tool:

This, however, is not the intended result. The intended result is the video in this post:

It turns out his example eluded me to how the beams actually worked, and caused me to believe that beams would sort of triangulate in between multiple attachments, but once I actually created the system, I had been proven wrong.

local WaveNodes = game.Workspace.WaveNodes
local WaveWidth = 10
local NodeRows = {}
local OceanSize = 10

-- Creates nodes
for x = 1, OceanSize, 1 do
	local Row = {}
	for z = 1, OceanSize, 1 do
		local Node = Instance.new("Part")
		Node.Name = tostring(x).."-"..tostring(z)
		Node.CanCollide = false
		Node.Anchored = true
		Node.Orientation = Vector3.new(0,0,-90)
		Node.Size = Vector3.new(1,1,1)
		Node.Position = Vector3.new(x*WaveWidth,1,z*WaveWidth)
		Node.Parent = WaveNodes
		local Attachment = Instance.new("Attachment")
		Attachment.Parent = Node
		Row[z] = Node
	end
	NodeRows[x] = Row
end

--Creates beams between nodes
for x = 1,OceanSize,1 do
	for z = 1, OceanSize-1, 1 do
		local Beam = Instance.new("Beam")
		Beam.Parent = NodeRows[x][z]
		Beam.Attachment0 = NodeRows[x][z].Attachment
		Beam.Attachment1 = NodeRows[x][z+1].Attachment
		Beam.Color = ColorSequence.new(Color3.new(0,170,255))
		Beam.Width0 = 10
		Beam.Width1 = 10
		Beam.Enabled = true
	end
end

Is there any way I can connect these nodes that I generate within my script in a way that causes beams around them to be affected in both directions, as seen in the prior example. As these are only connected on a strip by strip basis, I believe this is why this occurs.
Here’s a video of how the water is generated (each strip generated at 0.1 second intervals to make viewing possible):

The intended result was made by @ScottyMcPiper, maybe he can help me in this situation? If he doesn’t, I’ll try mentioning the creator of Fishing Simulator.

I know this was a long thread, but I had to show all the steps I had done to get to here, thanks for reading, and any support on the issue is appreciated, as I want to get this ready for a game.

Edit: I realize several threads have been made about similar topics

5 Likes

Nobody has replied for a little under a full day, so I’ll mention the creator of Fishing Simulator, @Spynaz. Sorry for bothering you, I want to create this ocean effect, so if you could give hint to how you did it, and in what way that I am doing it wrong, it would be very much appreciated. Thanks!

If you were to connect each node with all 8 of it’s adjacent nodes, you could form a wave like structure, each beam being a sloping face. This probably wouldn’t work for extreme sizes such as the one in your picture, but would work for smaller waves.

I haven’t tested or tried anything like this so I’m concerned about beams not fitting together perfectly and beams overlapping each other (not sure if there’s any z fighting), but worth a try?

1 Like

Thanks for the suggestion! I’ll try it out as soon as possible. This is great since nobody has replied for a day. :slight_smile:

After further inspection in a test example, it appears this does not work, unless you can explain to me how to rotate this better for 8 nodes being connected:
Which turns into this madness when magnified to a width of 10:


https://gyazo.com/05b9f0a84df838e254226dddf7c1be0c
Your solution might actually work, but I need help on how to rotate these points in a way where they all will be straight.

This is what I was worried about. Try doing this for each node (each node has beams to its adjacent nodes, not just the one in the middle)

Hey there. Letting you know ahead of time that my system is not efficient and you should note that I believe Spynaz does not use physical nodes as I do. This will at least give you an idea of a better physical structure for the beams. Best if he responds himself. Enjoy!
Ocean.rbxl (24.5 KB)

9 Likes

Thank you so much!!! This will be so helpful!

The way I setup each beam was between 4 positions which I like to call “nodes” (they’re aren’t actual parts, just Vector3s). A beam has only two attachments however, so you have to position and rotate each attachment between two of the nodes.

2 Likes

Attachments have to be parented to a PartInstance, yet you said no parts were involved. Roblox does not allow you to just have an Attachment parented to a folder or the workspace. Another thing that is still puzzling to me is how you position these between the nodes. Do you put them just right between two nodes, like at a 45 degree angle? Does this create what a vertex deformation would do, or do I have to pair this up with more beams and nodes and attachments? Sorry for being confused and asking a lot of questions, this just is a very big subject.

I just have all of them parented in one part. Also yes, I position the attachment exactly between the two nodes, and angled in a way so that it’s facing towards them. It’s the same thing as creating a line between two points. You have to position it in the center between them and angle it properly.

4 Likes

Pardon the bump, but how did you detect if the camera was below the attachments/keep the player’s torso above the closest attachments? A for loop? I’d like to know! Thank you sir. ~ Fan of yours <3

1 Like

Also you must’ve done it on the server because if the waves go up on different players screens some may appear to be floating in mid air

1 Like

You mean how do I check if the camera is below the water?

No, the waves animate on the client. But there was a time value that was controlled by the server, which made every client’s waves sync

2 Likes

One more thing if you don’t mind. For about a week I’ve been making an alternate swimming system using BodyPosition (and the control module) but it’s not as good (or efficient probably) as the one in your game “Fishing Simulator”, my question is: how did you do it? It almost seems like you used Roblox’s default swimming state? Thanks <3

1 Like

I think I just set the state of the Humanoid to swimming or something like that. It’s been a while

1 Like

That was the first thing I tried, it jitters though. I think cause it keeps switching back to the other states but it’s ok if you don’t want to share your secrets. What I made is ok for now. I still love your work <3

1 Like