View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Videos

Abrir menú Cerrar menú
  • Colecciones
  • Todos los videos
  • Información

Más videos

  • Información
  • Código
  • 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.

    Capítulos

    • 0:00 - Introduction
    • 0:56 - Design around gestures
    • 3:28 - System gestures
    • 6:14 - Combination gestures
    • 7:43 - Custom gestures
    • 11:24 - Physical controllers

    Recursos

    • Human Interface Guidelines: Gestures
    • Forum: Graphics & Games
    • Human Interface Guidelines: Game controls
    • Composing SwiftUI gestures
      • Video HD
      • Video SD

    Videos relacionados

    WWDC24

    • Bring your iOS or iPadOS game to visionOS

    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

    • Plug-in and play: Add Apple frameworks to your Unity game projects

    WWDC21

    • Tap into virtual and physical game controllers
  • Buscar este video…
    • 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)
        }
      }

Developer Footer

  • Videos
  • WWDC24
  • Explore game input in visionOS
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines