So, I am working on a sinking ship game and one of its features is having the furniture slide around when at a certain angle. Although, I have ran into a problem where the furniture will clip through the ground and It is really annoying. I am currently using CFrame and I know CFrame isn't the best for stuff like what I am explaining. I haven't got any errors, I'm simply looking for a resolution and suggestion to this problem as I want to make sure I am able to implement this feature as it will really add detail into the game.
Hi I have a solution to your question!
So 1st you want to put all your furniture into a folder so you have them all in 1 place!
Then you probably want to an-anchor all the furniture once the ship is tilting so they slide off on their own.
You also want a set position of when to un-anchor the furniture
heres an example code:
01 | local furfold = game.Workspace.Folder |
02 | local ship = game.Workspace.ship |
03 | local furchild = furfold:GetChildren() |
04 | local furnum = #furchild |
05 |
06 | if ship.Orientation = = vector 3. new( 0 , 0 , 90 ) -- say the furniture will slide if the ship is tilted 90 degrees on the z axis. |
07 | for i = 1 , furnum do |
08 | local furniture = furchild [ i ] |
09 | furniture.Anchored = false |
10 | end |
11 | end |
Hope this helped!
Any questions? Just ask!