Terasology / Rails

Base rail module for minecarts and such
10 stars 17 forks source link

Carts Intersecting Blocks at End Segments #13

Open pollend opened 7 years ago

pollend commented 7 years ago

Carts, When they hit an end segment will pop off and act like a bullet rigid body. The problem is when the end segment leads straight into a block. The cart will pop off the segment and be immediately embedded in the block. This causes the cart to launch back onto the track.

Instead The cart should hit the block at the end of the segment and roll back. This behavior is because Rails Implements its own impulse solver that is separate from Terasology. This means that the cart will only respond to intersections with the world after it leaves the rail segment and changes from a kinematic body to a non-kinematic body.

output

eviltak commented 6 years ago

@pollend May I ask exactly why does Rails use a separate physics system? If we can get Rails to work with Terasology physics, all these problems can be avoided.

pollend commented 6 years ago

I don't think bullet has a way to fix an object onto a track. I've already played around with this pretty exhaustively and just settled on treating cart as a kinematic object and handling the impulses myself. It's not too bad since the impulses are linear in nature.

eviltak commented 6 years ago

@pollend I see. You've probably tried these already, but how about constraining the current velocity to (i.e. projecting it onto) the tangent of the rails surface on every update? Or using collidion objects that only collide with the trains as the "barriers" of a track? Just throwing some ideas out there that may work. What do you think?

pollend commented 6 years ago

I've already attempted that with normal bullet. If you look in the legacy branch it does that somewhat. The main issue with this is that bullet can't calculate the impulses properly since you're constantly adjusting them. I also had the problem where the rigidbody becomes desynced from the actual visible model.

eviltak commented 6 years ago

Okay, so let's keep the physics system as-is, since you have clearly tested various approaches extensively.