generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: boat staying afloat

Previous Thread :: Next Thread 
vastqud is not online. 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 is not online. 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 is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
23 Jun 2017 06:36 PM
thank you
Report Abuse
vastqud is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. vastqud
Joined: 10 Sep 2011
Total Posts: 2464
23 Jun 2017 07:07 PM
nice thanks greatly appreciated
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image