Streaming is available in most browsers,
and in the Developer app.
-
Explore game input in visionOS
Discover how to design and implement great input for your game in visionOS. Learn how system gestures let you provide frictionless ways for players to interact with your games. And explore best practices for supporting custom gestures and game controllers.
Chapters
- 0:00 - Introduction
- 0:56 - Design around gestures
- 3:28 - System gestures
- 6:14 - Combination gestures
- 7:43 - Custom gestures
- 11:24 - Physical controllers
Resources
- Composing SwiftUI gestures
- Forum: Graphics & Games
- Human Interface Guidelines: Game controls
- Human Interface Guidelines: Gestures
Related Videos
WWDC24
WWDC23
- Bring your Unity VR app to a fully immersive space
- Create immersive Unity apps
- Develop your first immersive app
- Take SwiftUI to the next dimension
WWDC22
WWDC21
-
DownloadArray
-
-
5:16 - Respond to a tap gesture
// Respond to a tap gesture. struct ContentView: View { var body: some View { RealityView { content in // For entity targeting to work, entities must have an InputTargetComponent // and a CollisionComponent! } .gesture(TapGesture().targetedToAnyEntity().onEnded { value in print("Tapped entity \(value.entity)!") }) } }
-
7:08 - Combine dragging, magnification, and 3D rotation gestures
// Gesture combining dragging, magnification, and 3D rotation all at once. var manipulationGesture: some Gesture<AffineTransform3D> { DragGesture() .simultaneously(with: MagnifyGesture()) .simultaneously(with: RotateGesture3D()) .map {bgesture in let (translation, scale, rotation) = gesture.components() return AffineTransform3D( scale: scale, rotation: rotation, translation: translation ) } }
-
9:33 - Create and detect a custom circle gesture
// Create and detect a custom circle gesture. // Get all required joints and check if they are tracked. let leftHandIndexFingerTip = leftHandAnchor.skeleton.joint(named: .handIndexFingerTip) // ... // Get the position of all joints in world coordinates. let leftHandIndexFingerTipWorldPosition = matrix_multiply(leftHandAnchor.originFromAnchorTransform, leftHandIndexFingerTip.anchorFromJointTransform).columns.3.xyz // ... // Circle gesture detection is true when the distance between the index finger tips centers // and the distance between the thumb tip centers is each less than four centimeters. let isCircleShapeGesture = indexFingersDistance < 0.04 && thumbsDistance < 0.04 if isCircleShapeGesture { // respond to gesture }
-
14:00 - Detect a connected game controller
// Detect connected game controller. // Add handler for when controller connects. NotificationCenter.default.addObserver( forName: NSNotification.Name.GCControllerDidConnect, object: nil, queue: nil) { (note) in guard let _controller = note.object? as GCController else { return } // Add controller input change handlers. _controller.physicalInputProfile[GCInputButtonA]?.valueChangedHandler = { //... } } // Poll for controller input if controller.physicalInputProfile[GCInputButtonA]?.pressed {... } if controller.physicalInputProfile[GCInputButtonB]?.pressed {... }
-
14:24 - Tag a RealityView to handle controller input
// Tag a RealityView to handle controller input. struct ContentView: View { var body: some View { RealityView { content in // Tag your RealityView to respond to controller input events. } .handlesGameControllerEvents(matching .gamepad) } }
-
-
Looking for something specific? Enter a topic above and jump straight to the good stuff.
An error occurred when submitting your query. Please check your Internet connection and try again.