100% Physics Based Cart System [V2.0 Update]

The throttle I built into these can be controlled with touchscreen, mouse, or arrow keys. Is there some particular way to drive the cart that you wanted that they don’t have?

These physics carts are soo good I did make my own tracks with the games file but I cant upload the vid.

I guess I didn’t notice that lol. Good work on this!

How to make generator track and how to anti-gravity?

I hard to make cart ride. where is model from?

One issue I have with this is that it automatically breaks even though I am driving and on the track. How would I fix this?

If you use the throttle control it will stay at the speed you left it at.

Do you want it to have a separate brake function and keep free-rolling when you aren’t giving it an input?

Yes. Are you able to do that? Also this issue is occurring even when I add an input and am driving.

I have noticed that this problem occurs because the if statement for if the player is seated in the cart, does not work. I am driving it around in the place you linked in your Original Post and when you drive around, after a few seconds, it automatically self-destructs while a player is in it and inputting keys.

Hello, I’ve tried using you’re cart system however It’s not easy to change the cart model. Any tips…?

Just use a mesh part of the new model you want to use, then use a weld constraint to that connecting to the “Base” part of the original cart, then make everything else invisible.

Great system. I’m not a scripter ( I’m a modeler ) and I’m looking to use this, I have imported it however I am having issues with collision groups. Is there an open source script to select a folder and It automatically sets the collision groups? As of now it just falls directly through the track!

This can really be made to a new game! thats awesome
and with better models and meshes that would looks so good

This is incredible! I’m going to use this just to learn how to accomplish a physics system in the future, thanks

Great system! However I’m having trouble finding a way to keep the cart on the rails the entire time at high speeds. Anybody have any ideas that might help me?

As @stravant said, you can add wheels under the tracks and make the Collision group for those only react with the rails.
I made a model for someone else that I’ve modified with tilting/turning bogeys for up and down hills, centering wheels to keep the train wheels centered on the rails, and wheels underneath the rails to keep the carriages from flying off the rails.
For a cart system that needs to climb steep slopes you may want to add a PrismaticConstraint and a spring to keep the wheels underneath the rails tight against the rails so the driving wheels don’t lose traction.
I use Collision groups to make it so the under wheels and centering wheels only collide with the rails and not the ties, Parts, or Terrain underneath the rails.
Here’s a link to a post with my model in it: How to make a train bounce up and down? - #2 by Scottifly

1 Like

This would be so good for a Minecraft type game or any resource gathering and building game not just those “Ride a cart to X” games.

All your work for the ROBLOX is awesome and so useful thank you Stravant!

Just a note on this, one of the goals I design into my cart systems is deliberately not staying on the tracks as aggressively as possible. There’s lots of ways to make a very robust cart system where it’s almost impossible to fall off but I feel that that kills a lot of the potential entertainment value so I try to find a good balance instead.

5 Likes

Is this system under any licenses or am I free to use it with credit?
and another question, what would be the best way to destroy the cart if no one has sat in it in a few seconds to prevent spam?

2 Likes

Awesome system! Thanks for sharing this.

I just wanted to add that the gamepad input wasn’t working for me. Apparently ‘UserInputService:GetKeysPressed()’ doesn’t return gamepad keypresses.
To fix it I added the following code after the ‘GetKeysPressed’ loop on line 138 of the ‘LocalCartUI’ localscript:

-- Handle gamepad inputs
for _, inputObject in pairs(UserInputService:GetGamepadState(Enum.UserInputType.Gamepad1)) do
	local direction = DIRECTION_FOR_KEY[inputObject.KeyCode]
	if direction then	-- ':GetGamepadState()' returns all states, and we only want the two triggers
		keyBasedThrottle += direction * inputObject.Position.Z	-- Throttle depends on how far we're holding (value between 0-1)
		isKeybasedDriving = true
	end
end

Might not be the best solution? But from my testing it seems to work…

1 Like

Was fiddling with this since it would be cool to use, but stuck one one small little problem

Is there a way to make a dummy cart, it wont take in any input, but still gets treated as a cart, example, another cart couples and still pulls it around

Tried removing all speed calls and bits, left coupling, but it just gets, heavy, and wont move at all.