[Solved] Physics car tyre - remove lateral motion

0 favourites
  • 6 posts
From the Asset Store
Complete the collection by purchasing Motion Universe Pt. 2
  • So basically I have tried to translate this tutorial to C2 event system.

    https://www.iforce2d.net/b2dtut/top-down-car

    It seems that in the example it just applies an impulse to the center of the object.

    void updateFriction() {
          b2Vec2 impulse = m_body->GetMass() * -getLateralVelocity();
          m_body->ApplyLinearImpulse( impulse, m_body->GetWorldCenter() );
      }[/code:c1txk97f]
    If I use that Mass * -getLateralVelocity it is just way too much force. Also I tried to set velocity to lateral x and y with all kinds of variations, but could't get it to work.
    
    Here is Youtube video from working car
    [youtube video="Y"]
  • I think this should be the main idea.

    I assume that could then be manipulated with some kind of friction value.

    So far I basically just managed to get some values out.

    You can push the tyre around with right mouse and rotate with left and right arrows.

    Web test

    CAPX

    Maybe R0J0hound, Yann or keepee could point me to the right direction

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Katala,

    i was trying to do something like this a while ago:

    https://dl.dropboxusercontent.com/u/53374990/Forum/car%20physics.capx

    the group with the wheel physics should be open.. use WASD to control car, if you drive forward there is a row of unattached wheels where you can see how they don't laterally move.

    I'm still not sure whether the physics is right, or whether it just needs fine tuning. Things like the collision polygon of the car, and wheel positions affect handling quite a lot.

    I was trying to go for a car that you could drift reliably without losing control, but it wasn't really successful

  • I don't have time to check yet nor do I have time to download the 164.2 version, but following the reference page you posted, the lateral velocity formula should be:

    currentRightNormalX = cos(car.Angle + 90)
    currentRightNormalY = sin(car.Angle + 90)
    dot = currentRightNormalX * car.Physic.VelocityX + currentRightNormalY * car.Physic.VelocityY
    lateralVelocityX = dot * currentRightNormalX
    lateralVelocityY = dot * currentRightNormalY[/code:29wqbxyj]
  • keepee, This is awesome! It seems to behave quite right. I think for "easy" drifting there should be somekind of spin prevention system.

    Yann, This also works if I remove that +90 part.

    Thanks a lot for helping me out! I can now continue to make some sort of weight tranfer and whatnot

  • Katala

    That's very weird and suspicious.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)