Collisions & Physics: Physics Material
We can adjust friction and restitution.
Overview
When we add Physics Body Components to our entities, there are a number of value we can configure. This post will focus on the Physics Material values, or the PhysicsMaterialResource.
There are two concepts here. Friction and Restitution. We can see the values in RealityKit when we add the Physics Body Component. Notice that Friction is broken into static and dynamic values.

- Static Friction: the body must overcome this amount of resistance to begin moving from a stationary position.
- Dynamic Friction: the resistance applied to a body already in motion.
- Restitution: how bouncy is this body?
Not that these values are combined with the corresponding values on the other physics body. For example, if we set the restitution values for the surface of a table and a ball both to 1, then the ball should keep bouncing forever †. However, if we lower the restitution on the table to 0, the ball will bounce a few times before coming to rest.
We can set these values in code too.
let physicsBody = PhysicsBodyComponent(
massProperties: .default,
material: .generate(staticFriction: 0.0, dynamicFriction: 0.0, restitution: 0.5),
mode: .dynamic
)
subject.components.set(physicsBody)
// or
let physicsBody = PhysicsBodyComponent(
massProperties: .default,
material: .generate(friction: 0.0, restitution: 0.5),
mode: .dynamic
)
subject.components.set(physicsBody)Video Demo
This video shows a subject sphere bouncing with three levels of restitution.
Example Code
struct Example066: View {
@State var subject = Entity()
var body: some View {
RealityView { content in
guard let scene = try? await Entity(named: "PhysicsMaterialResource", in: realityKitContentBundle) else { return }
guard let blueSpere = scene.findEntity(named: "Blue") else { return }
subject = blueSpere
scene.position.y = -0.4
scene.addChild(subject)
content.add(scene)
}
.toolbar {
ToolbarItem(placement: .bottomOrnament, content: {
HStack {
Text("Restitution:")
Button(action: {
updatePhysics(restitution: 0.0)
}, label: {
Text("0.0")
})
Button(action: {
updatePhysics(restitution: 0.3)
}, label: {
Text("0.3")
})
Button(action: {
updatePhysics(restitution: 0.7)
}, label: {
Text("0.7")
})
}
})
}
}
func updatePhysics(restitution: Float) {
// Create a new instance of PhysicsBodyComponent using the restitution value
let physicsBody = PhysicsBodyComponent(
massProperties: .default,
material: .generate(staticFriction: 0.0, dynamicFriction: 0.0, restitution: restitution),
mode: .dynamic
)
// We can assing an new instance of PhysicsMotionComponent to reset any existing velocity on the subject
let physicsMotion = PhysicsMotionComponent()
subject.components.set([physicsBody, physicsMotion])
subject.position.y = 0.8
}
}†Sometimes RealityKit Physics behaves unexpectedly, especially in volumes.
Support our work so we can continue to bring you new examples and articles.
Download the Xcode project with this and many more examples from Step Into Vision.
Some examples are provided as standalone Xcode projects. You can find those here.

Follow Step Into Vision