Version: 2019.3
Target Joint 2D
Constant Force 2D

Wheel Joint 2D

Switch to Scripting

Use the Wheel Joint__ 2D__ to simulate a rolling wheel, on which an object can move. You can apply motor power to the jointA physics component allowing a dynamic connection between rigidbodies, usually allowing some degree of movement such as a hinge. More info
See in Glossary
. The wheel uses a suspension “spring” to maintain its distance from the main body of the vehicle.

Properties

Property: Function:
Enable Collision Can the two connected objects collide with each other? Check the box for yes.
Connected Rigid Body Specify here the other object this joint connects to. Leave this as None and the other end of the joint will be fixed at a point in space defined by the Connected Anchor setting. Select the circle to the right of the field to view a list of objects to connect to.
Auto Configure Connected Anchor Check this box to automatically set the anchor location for the other object this joint connects to. (Check this instead of completing the Connected Anchor fields.)
AnchorA UI layout tool that fixes a UI element to a parent element. Anchors are shown as four small triangular handles in the Scene View and anchor information is also shown in the Inspector. More info
See in Glossary
The place (in terms of X, Y co-ordinates on the RigidBodyA component that allows a GameObject to be affected by simulated gravity and other forces. More info
See in Glossary
) where the end point of the joint connects to this object.
Connected Anchor The place (in terms of X, Y co-ordinates on the RigidBody) where the end point of the joint connects to the other object.
Damping RatioA joint setting to control spring oscillation. A higher damping ratio means the spring will come to rest faster. More info
See in Glossary
The degree to which you want to suppress spring oscillation in the suspension: In the range 0 to 1, the higher the value, the less movement.
Frequency The frequency at which the spring in the suspension oscillates while the objects are approaching the separation distance you want (measured in cycles per second): In the range 0 to 1,000,000 - the higher the value, the stiffer the suspension spring.
Angle The world movement angle for the suspension.
Use Motor Apply a motor force to the wheel? Check the box for yes.
Motor
Motor Speed Target speed (degrees per second) for the motor to reach.
Maximum Motor Force Maximum force applied to the object to attain the desired speed.
Break Force Specify the force level needed to break and so delete the joint. Infinity means it is unbreakable.
Break Torque Specify the torque level needed to break and so delete the joint. Infinity means it is unbreakable.

Details

(See also Joints 2D: Details and Hints for useful background information on all 2D joints.)

Use this joint to simulate wheels and suspension. The aim of the joint is to keep the position of two points on a line that extends to infinity, whilst at the same time making them overlap. Those two points can be two Rigidbody2D components or a Rigidbody2D component and a fixed position in the world. (Connect to a fixed position in the world by setting Connected Rigidbody to None).

Wheel Joint 2D acts like a combination of a Slider Joint 2D (without its motor or limit constraints) and a Hinge Joint 2D (without its limit constraint).

The joint applies a linear force to both connected rigid body objects to keep them on the line, an angular motor to rotate the objects on the line, and a spring to simulate wheel suspension.

Set the Maximum Motor Speed and Maximum Motor Force (torque, in this joint) to control the angular motor speed, and make the two rigid body objects rotate.

You can set the wheel suspension stiffness and movement:

Stiff, barely moving suspension…

  • A high (1,000,000 is the highest) Frequency == stiff suspension.

  • A high (1 is the highest) Damping Ratio == barely moving suspension.

Loose, moving suspension…

  • A low Frequency == loose suspension.

  • A low Damping Ratio == moving suspension.

It has has two simultaneous constraints:

  • Maintain a zero relative linear distance away from a specified line between two anchor points on two rigid body objects.
  • Maintain an angular speed between two anchor points on two rigid body objects. (Set the speed via the Maximum Motor Speed option and maximum torque via Maximum Motor Force.)

For Example:

You can use this joint to construct physical objects that need to react as if they are connected with a rotational pivot but cannot move away from a specified line. Such as:

  • Simulating wheels with a motor to drive the wheels and a line defining the movement allowed for the suspension.

Hints

Wheel Joint 2D behaves differently to the Wheel ColliderAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary
:

Unlike the Wheel ColliderA special collider for grounded vehicles. It has built-in collision detection, wheel physics, and a slip-based tire friction model. It can be used for objects other than wheels, but it is specifically designed for vehicles with wheels. More info
See in Glossary
used with 3D physics, the Wheel Joint 2D uses a separate Rigidbody object for the wheel, which rotates when the force is applied. (The Wheel Collider, by contrast, simulates the suspension using a raycast and the wheel’s rotation is purely a graphical effect). The wheel object will typically be a Circle Collider 2D with a Physics Material 2DUse to adjust the friction and bounce that occurs between 2D physics objects when they collide More info
See in Glossary
that gives the right amount of traction for your gameplay.

To simulate a car or other vehicle:

Set the Motor Speed property to zero in the inspectorA Unity window that displays information about the currently selected GameObject, Asset or Project Settings, alowing you to inspect and edit the values. More info
See in Glossary
and then vary it from your script according to the player’s input. You can change the value of Maximum Motor Force to simulate the effect of gear changes and power-ups.

Zero frequency:

Zero in the Frequency is a special case: It gives the stiffest spring possible.

Target Joint 2D
Constant Force 2D