Hi, I have some water I made from 4 layers. But I want to be able to swim in it and for my boat in the picture to float.
And the parts:
Hi, I have some water I made from 4 layers. But I want to be able to swim in it and for my boat in the picture to float.
And the parts:
I know I can use HighPerformanceWater for swimming but I donāt know how to make certain materials float.
buoyancy is a complicated topic, especially if you want the shape of the part to determine how it floats
On a more fundamental level, you can use Archimedeās principle, stating that the force acting on an object is equal to the force cause by the amount of water displaced. On wikipedia, youāll see Fa = ĻgV
, where Ļ is the density, g the gravity, and V the volume of water displaced
This works great if you have a cube or a cylinder or some shape, being submerged along its axis, you can simply calculate the volume, and getting the force is easy. However, it becomes much harder if the object is slanted, or if you want to calculate the torque being applied to the object, due to one side being more submerged that the other (relative to the centre of mass)
One way Iāve seen people tackle this problem (Iām not too familiar with the possible solutions, so other people might have a better answer) is to calculate the force on an arbitrary amount of points placed within the solid
For example, if you decide on using 50 points to model a wedge, you can have a script place the points inside the wedge, and assigning each point 1/50 of the volume of the wedge. Then, when you detect that one of the points became submerged, apply a force of Fa = ĻgV/50
upwards at that point, (the point could be an attachment with a vector force inside). The roblox engine would then take care of the torque calculations and stuff
For your boat, and the character, you can probably ignore torque, and just make them stay upright.
For the Character, you can probably approximate it as a cube (or rectangular prism since the sides are different), and the volume is just 2*1*h
where h is the height submerged (make sure to clamp it from 0 to 3), using the standard R6 character sizes
For the boat, calculating the displacement of water will be more tricky. A good modelisation of the boat would be an ellipsoid (x^2/a^2ā + ā y^2/b^2ā + z^2/c^2ā = 1
), and then you can do an integral over the volume, limiting z to how far the boat is submerged (making the dz integral from -c to z, to keep z in your final answer. z would be -.25*c if the boat is submerged 75%)
This calculus I will assume means nothing to you, so um, you can always approximate the boat as another cube
I found a way earlier but wow⦠Iām gonna mark you solution just for writing all that
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.