vastqud
|
  |
| Joined: 10 Sep 2011 |
| Total Posts: 2464 |
|
|
| 23 Jun 2017 06:30 PM |
I need some pointers on how I can make a boat stay afloat in water.
I'm not talking about the terrain version of water, but rather an anchored, un-cancollided part that looks like water.
I have a boat model that's all welded together correctly, but I dont quite know how to make it "float" on the water part. Should I have a loop constantly checking if it's on the water, and if so, increase the position of the boat on the Y axis, or is there a better way to go about this?
Any help will be greatly appreciated. |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 23 Jun 2017 06:33 PM |
Create a group in workspace that refers to water (or a folder, your choice)
Take your boat objects and detect if they fall within any water regions (region3)
If it does, apply a constant force to it (implying it's physics based) to all critical areas to make sure it doesn't go lopsided. Remove or neutralize this force if it is no longer below water. |
|
|
| Report Abuse |
|
|
vastqud
|
  |
| Joined: 10 Sep 2011 |
| Total Posts: 2464 |
|
| |
|
vastqud
|
  |
| Joined: 10 Sep 2011 |
| Total Posts: 2464 |
|
|
| 23 Jun 2017 06:46 PM |
ok i have one question since i have never worked with region3 before...
how do i set up the region3 and detect if any boats are within the water region? the wiki article isnt too helpful in my case |
|
|
| Report Abuse |
|
|
vastqud
|
  |
| Joined: 10 Sep 2011 |
| Total Posts: 2464 |
|
|
| 23 Jun 2017 06:48 PM |
ok so i just found out how to detect parts in a region3 but i still need some guidance on how to set it up so the region3 is over the water regions
any help will be appreciated |
|
|
| Report Abuse |
|
|
vastqud
|
  |
| Joined: 10 Sep 2011 |
| Total Posts: 2464 |
|
|
| 23 Jun 2017 06:55 PM |
| sorry for the multiple posts, but would i manually try to find the vector3 values to create the region3, that would go over the water? |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 23 Jun 2017 07:03 PM |
local waters = {}
for i,v in pairs(game.Workspace.Water:GetChildren()) do
local regionOffset = v.Position - Vector3.new(v.CFrame.rightVector, v.CFrame.upVector, v.CFrame.lookVector) * v.Size/2
local regionMin = regionOffset local regionMax = -regionOffset
local newRegion = region3.new(regionMin, regionMax)
table.insert(waters, newRegion) end
Something like that. Not too familiar with regions, and I might have screwed up the vectors. Haven't tested this, take it with a grain of salt lol
As for getting the parts inside the region, either do some maths or use Workspace.FindPartsInRegionWithIgnoreList |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 23 Jun 2017 07:06 PM |
| You would need to go through the waters array every update and find parts in each region with the ignore list. |
|
|
| Report Abuse |
|
|
helloburp
|
  |
| Joined: 26 Aug 2011 |
| Total Posts: 14376 |
|
|
| 23 Jun 2017 07:06 PM |
| The ignore list consisting of anything that isn't the boats, I guess lol |
|
|
| Report Abuse |
|
|
vastqud
|
  |
| Joined: 10 Sep 2011 |
| Total Posts: 2464 |
|
|
| 23 Jun 2017 07:07 PM |
| nice thanks greatly appreciated |
|
|
| Report Abuse |
|
|