You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I’m attempting to create a movement system for ships where players can control direction, speed, and elevation of their ship (if applicable).
- What is the issue? Include screenshots / videos if possible!
Videos:
I’m trying to make my target part (stand in for a ship)
-
Maintain elevation if some external force like another block hits it exerts force on it (As if it was anchored)
-
Maintain orientation and elevation if it hits a slope and tries to move onto it. Eg. boat hits a slope in the map, orientation should stay (0, y-value, 0) and its elevation shouldn’t change basically causing the slope to act sort of like a wall
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Here are some solutions I’ve considered:
-
PlaneConstraint (to prevent height changes), won’t really work because I’m planning on having ship types that can elevate and descend (ie. subs and zepplins) and if these ship types use the plane constraint to ascend and descend it’ll create a headache later on when dealing with the map and having these glitch into walls
-
Custom collision groups (attempt to deal with both) - have vertical invisible walls so that ships can’t change orientation or climb angled surfaces on the map; won’t work because of aforementioned ship types that could apply external forces to lower and raise other players’ ships
-
Checks every heartbeat to correct orientation and height of each ship on the map - seems quite inefficient and unnecessarily resource intensive
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here’s my setup for the ship part:
local linearVelocity = Instance.new("LinearVelocity")
linearVelocity.VectorVelocity = Vector3.new(0, 0, 0)
linearVelocity.MaxForce = math.huge
linearVelocity.Attachment0 = attachmentMain
linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
linearVelocity.Parent = boatPart
local vectorForce = Instance.new("VectorForce")
vectorForce.Force = Vector3.new(0, boatPart:GetMass() * workspace.Gravity, 0)
vectorForce.Attachment0 = attachmentMain
vectorForce.Parent = boatPart
local alignOrientation = Instance.new("AlignOrientation")
alignOrientation.Attachment0 = attachmentMain
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
alignOrientation.RigidityEnabled = true
alignOrientation.Enabled = true
alignOrientation.Parent = boatPart
For movement, I adjust the linear velocity, and I rotate the cframe since changing the target orientation of align orientation seemed to cause a little bit of input lag when I tested it out. If there’s something I should adjust with this also please let me know!
I appreciate any help in advance!