What do you want to achieve? Keep it simple and clear!
I am trying to create a bike system that keeps the bike upright on the X axis of a BasePart(treated as the “base” of the entire thing) that is facing 90 degrees perpendicular to the rest of the bike.
(the orientation indicator is showing what I mean)
What is the issue? Include screenshots / videos if possible!
My issue is that… well… It won’t work. The bike is either very wobbly or flings itself when I have the script running.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
My current version is the best, but it introduced problems like steering not working(I assume this has to do with the way it is rotating itself). The closest I came to solving this was using a script that aligns it using CFrame:VectorToWorldSpace(). This worked best, but no luck in stopping flinging and fixing steering.
here is a video of it.
(in the video, as I try to steer it, it does not follow.
code
align = --insert the "base" part mentioned above
RunService.Heartbeat:Connect(function()
local val = Vector2.new(base.Orientation.X, base.Orientation.Z).Magnitude -- this is not used at the moment, ignore
local xO = align.Orientation.X
local yO = align.AssemblyAngularVelocity.Y
local zO = align.AssemblyAngularVelocity.Z
align.Massless = true
local vec = align.CFrame:VectorToWorldSpace(Vector3.new(-xO, 0, 0))
align.AssemblyAngularVelocity = Vector3.new(vec.X, yO+vec.Y, zO+vec.Z)
end)
well i’ve never worked anything like that but you need to verify when the seat of bike get unoccupied you put the torque of the bike on low till it reaches the 0 speed in a low space to not run all the map and aswell when the bike fall to the ground you need to reset his main orientation, i can’t make any code now but that’s the idea.
I am currently on my phone so I can’t exactly provide any script related help, but the most I can tell you right now is to check out Align Orientation Hope this helps.
I don’t think you understand. The steering problem comes from the fact that the upright code does not work properly and is jittery. The solution will not solve any problems…
So you can try this you only need one attachment in the main part/the chassis. Then create an AlignOrientation set it to the attachment and set Mode to OneAttachment, MaxTorque to somewhere around 100000 (you can adjust this as needed), then under CFrame Orientation set it to 0, 0, 90
make sure your mainpart’s orientation is facing forward to front of bike and top to sky
like the part in the image below
image below shows the settings
as long as you are not applying any odd forces this should work to keep it up right better