I’ve been having an unusual issue with some of my models as of late. I build model locomotives and trains for 8 stud roblox railroading games. With some of my more recent creations, when the locomotives are running for any significant amount of time, they sort of explode at random. By explode, I mean the model is violently shot into the air with speed in the thousands of studs per second. I’ll try to include a video or screenshots as best I can. This happens seemingly at random with little to no warning. I’ve been trying to troubleshoot the thing for almost 8 months now and while I’ve gotten it more stable, it still randomly experiences this. Some more details about the engine and it’s construction:
The locomotive uses NWSpacek’s Vehicleseat 2 for powering the wheels. The engine is kept on the rails by “gliders,” which are basically small cylinders that sit in the gauge of the rails. Most of the mechanical components like the drive rods are there for show, they use hinge constraints to operate.
Something to note is that this issue isn’t specific to this model, just that this engine demonstrates it most egregiously. Of all the locomotives I’ve built only 3 of them are my problem children. Another unusual detail is that the issue only seems to happen when I’m using it in my game. I’ll provide a link to said game, but in most test studios the unit seems to work perfectly.
I couldn’t even list the number of changes and alterations I’ve made to try and find the source of the problem. Things like using invisible wheels to make unions non-colliding, adjusting hinges, swapping hinge orientation, collision removal for all non-essential drive parts, adjusting the VS2 settings for optimized running, disabling collision on all non-essential wheels and driveline components, replacing all hinges, replacing all prismatic constraints, disabling the front wheel VS2 hinges and replacing them with a passive axle, re-centering every hinge multiple times, and rebuilding the lead and trailing trucks. This isn’t a comprehensive list as I’ve gone through around 300 versions of this engine in my many attempts to fix it.
Anyone have any ideas on what to try next? I’ve done just about anything under the sun I can think of and I’m out of ideas. I’m thinking it’s some sort of hinge issue but at this point I’m not sure anymore.
I can send or share files for any part of the build process. Even the bare chassis seems to have this issue.
Just looking for advice on what else I can try. I’ve been working on it for so long I don’t think I can give up now, but man is it frustrating. I’ll attach some photos and videos if I can get one of the loco exploding.
Link to the engine’s home game: The NXT Museum and Branch Line - Roblox
If you want to find it simply use the Keystone Shops teleporter, it’ll be on the farthest track in the back.
This video shows what an incident looks like. Obviously the shop roof caught the thing but it just does this with no warning. The model also behaves like this if it’s running light engine (no cars behind it).
robloxapp-20220111-1216428.wmv (2.2 MB)
If I can provide anything else that would help find a possible problem source please let me know. I’m not opposed to sharing files of the thing if anyone wants to take a look.
Thanks in advance to anyone who can help!
Have you tried putting a BodyGyro | Roblox Creator Documentation in each car and the locomotive with the MaxTorque set to something like (50000,0,50000)?
It appears that the AngularOrientation link on that page is broken. I can’t find any reference to it other than the BodyGyro page.
The BodyGyro page has a broken link to the superseding feature, which should be the AlignOrientation constraint
@Scottifly I’ll try this immediately and get back to you once I have verifiable results. I’ve never even actually heard of this feature so I’m hoping it works lol. If I’m to understand correctly this will basically lock it to only left and right rotation? I’m hoping this wont interfere with gradients or anything. I’ll give it a shot, thanks.
I can’t imagine gradients on a railroad will be that much. If there is an issue try decreasing the MaxTorque to (10000,0,10000) or even lower.
As @chefdeletat mentioned the AlignOrientation might also work for you pretty well too, it’s more customizable than BodyGyro.
In looking at your gliders it may just be the fact that they seem pretty tiny. Tiny Parts sometimes pass through other Parts even without a lot of force or speed.
This may be something you can fix with this post I did a while back.
<How to make a basic train - #11 by Deadwoodx
Deadwoodx made a very basic train tutorial and I gave some suggestions along with a model I’d made as an example that moved pretty fast without “coming off the rails”. It has the large glider wheels I suggested to you. You can read the rest of the post to see my explanation of how my train works compared to how they made theirs work.
You are encountering a high mass ratio issue for the physics engine. Make sure you increase the density of small assemblies whose mass is much smaller than the rest. For example if the body of the engines is 100x more massive than the wheels, the results will be unstable. I imagine the different side rods are pretty light too.
Welp, this is def a collision problem. Have you made sure that the wheels of the train aren’t touching the other parts?
Edit: I had a very similar issue where my car would bounce and I later realized it’s because of the wheel’s interference with other parts. I’m going to give an example of how I solved my issue (Fig 1.0).
local train = ...
local folder = ...
for _ , wheel in pairs(train:GetDescendants()) do
if wheel.Name == "Wheel Mesh" then
for _ , object in pairs(train:GetDescendants()) do
if object:IsA("Part") or object:IsA("UnionOperation") or object:IsA("MeshPart") or object:IsA("WedgePart") or object:IsA("VehicleSeat") or object:IsA("Seat") then
if not object:FindFirstAncestor("Wheel") then
local Collision = Instance.new("NoCollisionConstraint")
Collision.Part0 = wheel
Collision.Part1 = object
Collision.Parent = folder
This (collision issues) is one of the things I spent the most time on. I’d been told collision error before and as such most of the loco is non-colliding. I’m going to act on chefdeletat’s suggestion and start modifying the density of different parts on the loco in the hopes that will fix the issue. I was not successful in modifying the unit to use AlignOrientation or a BodyGyro, it seemed to cause more issues than it solved.
@chefdeletat In fixing the mass ratio issues should this only apply in proportion to reciprocating parts or the engine as a whole? I can increase the density of the rods and moving components to help but should I only be doing this to components are powered or anything with a hinge? For example should I
- Adjust the density of the powered part of the wheels only to compensate
- Adjust the density of the wheels and all parts welded to the wheels
- Adjust the density of any moving part on the loco
- Adjust the entire loco so most parts have a similar resultant mass
I guess the heart of my question is “Should I adjust it so that the mass the powered parts is trying to move is relatively close to the mass of the powered parts themselves” Sorry if this is difficult to understand I don’t think I’m articulating my question well and I apologize.
Additionally I can try decreasing the density of the boiler (the large cylinder that makes up the core of the loco) so that it is a smaller mass part and see if that helps.
Again a huge huge thank you to everyone who has been kind enough to assist thus far.
The best is to increase the density of the parts where you expect large forces to be transmitted, and decrease the density of parts that contribute to these forces. For example the side rods and wheels would probably feel the weight of the locomotive, therefore it’s better to increase their density and at the same time adjusting down the density of the locomotive. If there are small parts between the cars (car couplers) they may need to be made heavier as they feel the mass of the entire train behind it.
If you are using AlignOrientation or AlignPosition, make sure to enable ReactionForcesEnabled otherwise you will get non-physical behaviors.
Unfortunately after testing just about everything in this thread I still haven’t been able to improve the stability of the model. Altering density of parts either resulted in no change or significant detriment to the running quality and I cant get BodyGyro’s or AlignOrientation to function. As of right now my last resort is to try @B2ontwitch’s code.
How should I integrate this into the engine? Would I simply paste it into a script in the grouped final model and change the names of certain components to reflect my model? Or is this a code I can execute once and it will assist in finding parts that collide? I’m sorry to say I’m a total novice in terms of how to integrate or write code as I’m far more involved on the building side of things.
Again I want to extend my sincerest thanks to everyone helping me thus far.
Did you try the model I had included in the link I posted above? I’ve pasted it below here.
It’s been up to huge forces on the VectorForces in each car and performs really well. I’ve gone up to 40,000 on the X axis for the forces (just sit on the train in test mode and manually click on both red parts, then select both VectorForces and put in 1000 and see how it works. You can increase the X force to see how fast it’ll go, but when you get to about 40,000 it starts to move too fast and will derail. The -1000 in the Y value is there to help push it down onto the tracks as well.
The Part Density hasn’t been changed much, but there aren’t too many involved either.
Train Experiment.rbxl (39.8 KB)
What my code is supposed to do is make every wheel in the train model not collide with parts that aren’t wheels. Hopefully this example is more clear:
1. Click on the + icon on the train model
2. Click on Script
3. Group all the wheels into a model called "wheels" parented to the train model
4. Group all of the other parts into a model called "other_parts" parented to the train model
train = script.Parent -- This gets the model of the train
for each , wheel in ipairs(train.wheels:GetChildren()) do -- This gets all the wheels
for each , part in pairs(train.other_parts:GetChildren()) do -- This gets all of the other parts
local no_collision_constraint = Instance.new("NoCollisionConstraint")
no_collision_constraint.Part0 = wheel
no_collision_constraint.Part1 = part
no_collision_constraint.Parent = workspace
-- This script will go through all the wheels in the model and make it not collidable with everything else that's not a wheel.
It’s been almost two weeks so I’m sorry for dragging my way back into this thread but after trying everything within I still can’t get the model to work. I’m wondering if has something to do with an undo error I had during construction. At this point I’m just going to use the model for static display and take it as a lesson learned. Thanks everyone for all your help.
Did you even have a look at my Train Experiment model?
I use a single vertically hinged wheel that is just slightly narrower than the width between the rails. Instead of your tiny tiny sliders it actually spreads some resistance to the forces applied by the train across a wider area, and spins to counter any friction. I used 2 of these wheels per car, spaced close to the axles of the front and rear bogies.
Try reducing the amount of moving parts your train has (unions, animations), I usually see this happen when there are a large amount of moving parts on something
I cracked it! As it turns out apparently the physics engine has issues with large coupled wheelbases (essentially anything over 6 coupled wheels). By “splitting” the main rod and adding a hinge it seems to have completely stabilized the model. Will have to keep this in mind for future builds.
@Scottifly I did try implementing your solution earlier in the thread and at the time it did not fix the problem. I did switch to much larger frictionless gliders on the final model. Your solution did help smooth out the way it handles in sharper curves but it was not the root cause. Your other suggestions were very helpful in planning for future builds as well.
Why this hinge implementation seems to work is beyond me, but I’m finally happy to have the thing operating. Many thanks to everyone in the thread who offered suggestions and help! While most of the postings here didn’t have the complete solution you guys contributed a few things that have also helped smooth out and improve the model so it’s a win-win situation.
Thank you all so very much!
I’ve also had issues with complex physics structures getting glitchy as well. I didn’t even think about it until I looked at your original images showing something like 25 hinges per side.
Also as @chefdeletat mentioned, making sure all the moving components have similar Density Properties has helped me when using complex items.
I just found out a solution yesterday to an issue I was having with my suspension vehicles. My wheel Hinges are linked by a twin A-arm type suspension and sometimes when you stopped a vehicle (or especially when you hit a wall) one or more of the wheels would suddenly start rotating at high speeds even though the AngularVelocity of the Hinge was at 0.
I have pretty high MotorMaxTorques in the wheels for hill climbing which may contribute to the glitch and I fixed it by setting the MotorMaxTorques to a much lower value when the VehicleSeat is reading a Throttle value of 0. When the Throttle is 1 or -1 I increase the MotorMaxTorques back to their origina values.
You should also mark your post above as the Solution in case anyone else is searching the forums for a similar problem.