Adjusting Physics in Unity VR

Using Physics Materials Adjust the Feel of the Sports Equipment

Jordan T Kay
6 min readApr 25, 2024

The basketballs are interactable in that the player can grab them and throw them, but they do not feel like a basketball. When the player throws the basketball it does not act the way you would think a basketball would act. It does not fly through the air, nor does it bounce. It kind of just drops and dies.

We need to fix this by using a thing called…

PHYSICS MATERIALS

Physics Materials help define properties on the collider’s surface such as friction and bounciness. Physics Materials are referenced through the object’s collider component.

To create a Physics Material go to…
ASSETS > CREATE > PHYSICS MATERIAL

Physics Materials have 5 properties….

  1. DYNAMIC FRICTION → Specifies the level of friction between the surface of one object and another when they are moving or sliding against each other.
    — Property Value is between 0–1
    — 0 being there is no friction, like sliding on ice, it is very smooth
    — 1 being very high friction, like trying to move rubber against a sticky surface
  2. STATIC FRICTION → Specifies the level of friction between the surface of one object and another when they are stationary.
    — Property Value is between 0–1
    — 0 being there is no friction, like trying to stay still on ice, it is very slippery
    — 1 being very high friction, like wearing a new pair of basketball shoes on a nice clean court and attempting to slide your foot around
  3. BOUNCINESS → Defines how bouncy the surface is, and how much other objects can bounce off it.
    — Property Value is between 0–1
    — 0 being the surface is not bouncy at all (think of soft clay) and other colliders lose kinetic energy upon hitting it
    — 1 being the surface is very bouncy (think of rubber) and colliders bounce without any loss of kinetic energy
  4. FRICTION COMBINE → Defines how the physics system calculates friction between two colliders, based on each collider’s Friction value.
    — Applies to both Dynamic & Static Friction
  5. BOUNCE COMBINE → Defines how the physics system calculates bounce between two colliders, based on each collider’s Bounciness value.

When two colliders are in contact, the physics system uses the surface properties of each collider to calculate the total friction and bounce between the two surfaces. The properties FRICTION COMBINE and BOUNCE COMBINE provides 4 options to control how the physics system calculates the total friction/bounce between two colliders
1. MAXIMUM → Use the largest of the two values
2. MULTIPLY →
Use the sum of one value multiplied by the other
3. MINIMUM →
Use the smallest of the two values
4. AVERAGE →
Use the mean average of the two values
The properties are in priority order, meaning if two objects collide and both have different options selected for their respective colliders, the one with the higher priority option is used.

There are other existing properties that we can adjust to configure the feel of the basketball. These properties are nested within the Rigidbody and the XR Grab Interactable component.

RIGIDBODY COMPONENT

Rigidbody provides a physics-based way to control the movement and position of a GameObject.

Within the Rigidbody component we should adjust the following properties…

  1. MASS → Defines the mass of the GameObject in kilograms
  2. DRAG → Defines how quickly the velocity of the GameObject decreases over time.
    — Drag refers to the linear drag of an object. When an object moves through a medium (such as water or air), drag slows down it’s movement by applying force opposite to its direction of motion (mimicking the effects of air resistance/friction within the virtual environment)
  3. ANGULAR DRAG → Defines how quickly the velocity of the GameObject’s rotation decreases over time.
    — Similar to linear drag, angular drag applies a resisting force to rotational motion, slowing down the object’s rotation. This is useful for simulating effects such as air resistance or friction on spinning objects.
  4. COLLISION DETECTION → Provides different methods for detecting collisions, such as discrete collision detection, which checks for collisions at fixed intervals, and continuous collision detection, which ensures accurate collision detection even for fast-moving objects.

Continuous collision detection modes use predictive algorithms to calculate collisions that happen between physics timestamps.

XR GRAB INTERACTABLE

Interactable component that hooks into the interaction system to allow basic “grab” functionality

Within the XR Grab Interactable Component we should adjust the following properties…

  1. THROW SMOOTHING DURATION — This is the amount of time over which Unity calculates the average velocity of an object after it’s thrown. It smooths out the changes in velocity over this duration.
  2. THROW SMOOTHING CURVE — This curve determines how much weight is given to the most recent frames when calculating the smoothed velocity of a thrown object. It affects the smoothing effect over time.
  3. THROW VELOCITY SCALE — This is a scaling factor applied to the velocity of an object when it’s released after being grabbed. It determines how much the object inherits the velocity of the hand or controller that released it.
  4. THROW ANGULAR VELOCITY SCALE — Similar to the velocity scale, this property is a scaling factor applied to the angular velocity (rotation speed) of the object when released. It controls how much the object inherits the rotational motion from the hand or controller that released it.

THROW SMOOTHING CURVE
This property is represented by a graph, where the x-axis represents frames and the y-axis represents the weight/influence given to each frame’s velocity when calculating the smoothed velocity. The “curve” determines how this weight changes over time.
X-AXIS (TIME/FRAME) — Each frame during which the object is in motion represents a point on the x-axis. Time progresses from left to right.
Y-AXIS (WEIGHT/INFLUENCE) — The value of the curve at any given frame represents the importance given to that frame’s velocity when calculating the smoothed velocity.
CURVE SHAPE — The shape of the curve determines how much emphasis is placed on recent frames versus older frames…
— A curve that rises quickly and flattens out indicates that recent frames have more influence resulting in quicker response to changes in velocity
— A curve that rises gradually and remains high indicates that even older frames have significant influence, resulting in a smoother, but slower response to changes in velocity

TEST

By using Physics Materials on the sporting equipment and the ground, as well as adjusting the Rigidbody and Grab Interactable properties, we are able to configure a nice feel for…

BASKETBALLS

TENNIS BALLS

FOOTBALLS

BEACHBALLS

--

--

Jordan T Kay

Join my journey into game development with Unity. Learning all I can to produce quality games. 🚀