I'm working on a side scroller game with a cart on a track. The track has moderate curves (+/- 45 degrees or so from horizontal) and will have some missing tracks so the cart has to jump. The physics doesn't behave the way I expect it to so I am trying to figure out if I'm missing something. How can I get a cart to move along a track (and be able to jump)? My experience up until now is mostly making all my objects triggers and controlling movement by transform.Translate.
What I've tried:
1. Constant Force on the cart to keep it moving forward along the track (local forward) as well as gravity and/or local downward force to keep it pressed down on the track.
2. Wheel colliders, which seem to do a decent job.
3. Narrow (box) colliders for the track's rails. I hope this isn't messing up my physics because of the edge effects of a narrow wheel on a narrow rail.
4. Using AddForce to jump. This has been the most confusing. The cart sometimes flips around if the jumping force is too high. If I lower the force a little then it doesn't jump at all. Again, I wonder if it's due to edge effects of the colliders.
5. Jumping with rigidbody.velocity rather than AddForce. It seems easier to control the velocity than it does to fine tune the forces needed.
I'm open to reworking any part of this game. I'm using 3D objects for the cart and the track, but am open to using 2D physics for the interactions.
I've tried a few different colliders on the cart and on the track. There was no clear winning combination for me to use.
↧