Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

2D Wheel Joint physics

Discussion in 'Physics' started by TheOnlyPhenix, Sep 7, 2018.

  1. TheOnlyPhenix

    TheOnlyPhenix

    Joined:
    Sep 4, 2017
    Posts:
    2
    I have experience with the 3d side of unity. I'm trying to work on my first 2d game, its a side view racing game.
    I've been trying to work with Wheel Joint 2D. It doesn't seem to be made for this purpose. They have only 2 parameters, setting max torque and target speed.
    Then there is no way to read RPM directly from the Wheel Joint 2D. You have to get angular velocity then manipulate that with the rest of your formulas.
    Anyways what i'm getting at is that i can't seem to get anywhere with it. Does anyone know of a better way of approaching this? Is there an asset for sale or am I just straight up using the wrong approach?
    I'd love to hear your thoughts!
     
  2. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    I'd say you're using the wrong approach, but that might not be the case, as it depends on what you're doing. I rolled my own.

    Melvin May, the guy responsible for 2D physics in Unity, is a bit of a doer and not much of an explainer. As such, he's got a few demos here, which you should dissect to understand how he's done things, and what can be done with those things.
     
  3. TheOnlyPhenix

    TheOnlyPhenix

    Joined:
    Sep 4, 2017
    Posts:
    2
    I looked into that demo by Melvin May. And it seems that its only supposed to be used for very simple vehicles. It appears there is no way to manipulate the variables to make it what i want it to do. Hint: Act like an actual car. Not just instant torque, and a set max speed.? In which there is no place to read current speed from the script. You just have to get rigidbody velocity.
    Personally, I think the WheelJoint2D should either be redone, or keep that for simplicity sake, and make an entirely new 2d wheel controller.
    Thanks for the help anyway, I'm just going to give up on that project for the time being. Unity is really the only engine i know.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    1,510
    I've been explaining stuff for users for many years without issue. You certainly couldn't understand my explanation a while back but it seemed you wanted simplistic yes or no answers only. I don't think promoting me as "not much of an explaner" is valid but you're welcome to your opinion on this.

    The wheel joint isn't created by Unity, it's a thin wrapper around Box2Ds wheel joint. The reason I mention this is that if you search for that, maybe you'll get extra information that'll help.

    If you look at the docs you should see "jointSpeed" which is the rotational speed of the joint.

    What "variables" are these? What do you mean by "Act like a car"? In the end it's a simple motor with a spring-based suspension.