CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.2k stars 4.11k forks source link

Weird skidding behaviors (intended?) #13307

Open Coolthulhu opened 9 years ago

Coolthulhu commented 9 years ago

A skidding vehicle will move like it did before collision, just rotating around own center.

This can cause it to immediately reverse direction when it recovers from skid.

Additionally, vehicle velocity after skidding is fully retained regardless of its orientation. A vehicle can reverse direction with nearly no loss in speed due to a "lucky" skid.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

i2amroy commented 9 years ago

I'd say that holding all of their momentum is definitely strange. On the other hand doing a purposeful skid like that in real life is one of the ways to rapidly reverse your direction while still holding some of your momentum (i.e., redirect your velocity to the side enough that it is pointing backwards instead of attempting to decelerate to a stop and then go backwards).

kevingranade commented 9 years ago

This shouldn't happen. The 'right' way to handle this AFAICT is to track a vehicle momentum vector independently of vehicle facing, right now momentum is tracked as a scalar and facing supplies the direction.

i2amroy commented 9 years ago

That would give us some potential options later to deal with purposeful skidding and the whole "turn left to go right" type thing too. +1 from me.

mugling commented 8 years ago

Did vehicle traction updates address this?

Coolthulhu commented 8 years ago

Nope, traction only affects velocity, not direction.

mlangsdorf commented 6 years ago

Facing and movement are different tilerays in the current code. Did this get resolved when no one was looking?

kevingranade commented 6 years ago

Possibly, when did the movement tileray get added?

mlangsdorf commented 6 years ago

commit c4df7ad9be99cabe27dce1eeb520845f381a19bb in 2012. WTF?

kevingranade commented 6 years ago

Uh, you cant have skidding at all unless you have different rotation and facing vectors. Feels like that should have been obvious, but it clearly wasn't.

The problem is likely that the skidding/traction model is weird.

mlangsdorf commented 6 years ago

My confusion was that the movement tileray was added in 2012, so I'm not sure how this issue ever came up. But then I dug through the vehicle movement code in map.cpp, and now I am confused about different things and I'm pretty sure this is still an issue.

Relevant code bits:

    // Where do we go
    tileray mdir; // The direction we're moving
    if( veh.skidding || should_fall ) {
        // If skidding, it's the move vector
        // Same for falling - no air control
        mdir = veh.move;
    } else if( veh.turn_dir != veh.face.dir() ) {
        // Driver turned vehicle, get turn_dir
        mdir.init( veh.turn_dir );
    } else {
        // Not turning, keep face.dir
        mdir = veh.face;
    }

    tripoint dp;
    if( abs( veh.velocity ) >= 20 && !falling_only ) {
        mdir.advance( veh.velocity < 0 ? -1 : 1 );
        dp.x = mdir.dx();
        dp.y = mdir.dy();
    }

You can be going direction 0 with face.dir()==0 and move.dir()==0, make a hard right turn so that face.dir()==90, skid out of control and spin out to face.dir()==135, and then you're heading SSW with your initial velocity less whatever slowdown you had in the skid.

A better model would have would have the vehicle always moving on the move vector, and being out of control would occur whenever there was too much divergence between face and move. Thrust/acceleration would mostly occur on the face direction, but there would be lateral friction to reduce the move vector and make it easier to align the move vector and the face vector.