Make your first Apple Vision Pro app!
Vložit
- čas přidán 21. 10. 2023
- Hi everyone, today I'm going to show you how to make an simple game for the new Apple Vision Pro!
You'll learn the fundamentals of visionOS, including:
• visionOS
• realityKit
• swiftUI
• gestures
• image-based lighting and shadows
Assets download: madebyyuma.gumroad.com/l/visi...
Final source code download: madebyyuma.gumroad.com/l/visi...
This is a fun tutorial, so I hope you like it!
#visionpro #visionos #spatialcomputing - Věda a technologie
Three months ago, you created this amazing video. You need to create more videos. This is the most useful video I've seen in the field of developing for VisionOS.
Thanks for your kind words, I’m super glad you find this tutorial useful!
Thanks Yuma for sharing this great tutorial! I'm new to both swift and swiftUI, your tutorial addresses many aspects of creating a complete VR application for VisionOS. It is a great starting point for anyone new in this field. It is impressive that know all this stuff at your age!
Thanks for your kind words!
please make more video like this! And especially for non-ever Swift people.
Great tutorial man, new to visionOS here and your videos are easy to follow and very informative.
Great tutorial! Thank you so much! Please keep going with VisionOS, really helpful
Thanks for your kind words! I’ll try to make some follow up tutorials when I’m free from school and other projects 😅
This is awesome and so useful. Great job. Hope to see more!
Great job. Can't wait to watch more
Love to see a video now that the AVP is out where you show how to deploy to the headset :)
Hi! From the future here 😊
Very nice clean presentation! Thank you for sharing. I just finished the Harvard CS50 python course and made a cribbage and dice (10,000) game for my final projects. I've made a few games for iOS and Unity, too.. but I'm really excited to make a ProVision 'Dice 10,000' game and your tutorial has inspired me to start working on it ! 👍
Thanks, I’m glad you found my tutorial helpful! Best of luck with your Vision Pro game!
vision os development is exciting!
Great job, I subscribed and i'm looking forward to your next vision pro lesson. Keep up the great work.
Thanks for subscribing! I’m glad you liked the tutorial!
great tutorial! I come from Unity and Unreal so this was a wonderful introduction to using Swift for Apple Vision Pro. For some reason my dice don't cast shadows though even though I have the HDR scene and code set up the same as you.
Hi! Adding the GroundingShadowComponent should be enough to add shadows to the dice. It could also be a bug since the VisionOS is still in a beta state, so restarting Xcode might help. Hope this helps!
@@AnyoneCanCode no dice (lol) so probably a bug. Thank you though!
Great tutorial, thanks for putting this together! Any plans to make a more in depth visionOS tutorial? That's something that I would pay for as a beginning in Swift.
Also, I suggest slowing down a bit and walking through the concepts a bit more. I had to pause every few seconds because you were going so quickly :) otherwise great!
Thanks! I’ll see if I can put together another tutorial when I’m free.
Thanks for your feedback as well! I’m trying to strike a balance between keeping the tutorials short and adding more detail, since I don’t want to bore anyone 😅 I’ll take this into consideration though!
Thanks Luffy !
hi,
can you help me how I can manipulate blend shapes of a usdz file?
I would appreciate any advice
Great tutorial, bro make an adavance level demo. Thanks for your efforts
I could really use your help creating a vr/augmented realty app for vision pro.
Thank you! This is the best tutorial I've seen on this topic yet. One question, one of Apple's tutorials recommends adding .usd models into a swift package so that they are optimised automatically at run time. Have you tried this? Does it change anything in the way you access and address the model?
Thanks! If you want to load the model from a swift package, you will need to add an import statement for your package. You can then load the entity using the .entity(named:) function, which will load your .usd model! I would suggest taking a look at Apple’s “Hello World” sample code, which should answer what you’re looking for. Hope this helps!
Thank you I truly hope to create my first app soon. I will search your videos to see if you have anything on Unity to Vision OS? I hope you do, as I like the way you teach... I appreciate you...
Thank you! I don’t have any Unity tutorials yet, but I’ll definitely consider it!
please make more video like this!
Great video and thanks for the help getting started. Is it just me or does the dice hang around after you've closed the app? Is there a cleanup step missing from the app on its closure?
Thanks! I’m not aware of any cleanup steps for VisionOS apps because garbage collection should be handled automatically. It’s likely to be a bug in the simulator, but could also be something I missed!
Hello, what should I do If I want to rotate a component onDrag gesture instead of moving? (I need something like, when I drag left rotate to left and when I drag right rotate to right)
I've tried this:
.onChanged{ value in
let speed: Float = 0.1
var newAngle = value.entity.transform.rotation.angle + speed * Float((value.translation.width / abs(value.translation.width)))
if (newAngle < 0){
newAngle = 2 * Float(Double.pi) - newAngle
}
value.entity.transform = Transform(
scale: value.entity.transform.scale,
rotation: simd_quatf(angle: newAngle, axis: SIMD3(x: 0, y: 1, z: 0)),
translation: value.entity.transform.translation
)
}
But it does'nt work with negative angles
Good video. What minimum specs do you recommend for developing with the vision os simulator?
I’ve found the simulator works best on Apple Silicon Macs!
Thanks!
You’re welcome, and thanks for this! 😊
Great video! I was wondering what changes you made to the dice usdz file to make it movable. It seems that Reality Composer let you add behaviors that did this, but with the recent updates (i believe xcode 15.0 beta 8), reality composer is gone. Reality composer pro still exists but i cant find a way to add behaviors to an object on there.
Thanks! I didn’t do anything special to the usdz file to make it movable. You just have to make sure that you’re making the mesh object movable, since usdz files tend to add blank parent objects!
For the dice, i had to add some extra code to get the usdz’s children to fetch the actual mesh. Hope this helps!
Yes that helps, thank you! I think my issue was that (.first) wasn’t working since my usdz object had multiple children in a different order. Just had to do dice.children[1].children.first instead
My Object:
▿ 'Camera' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'Camera' : PerspectiveCamera
⟐ PerspectiveCameraComponent
⟐ Transform
⟐ SynchronizationComponent
▿ 'Cube' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'Cube_001' : ModelEntity
⟐ Transform
⟐ ModelComponent
⟐ SynchronizationComponent
▿ 'Light' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'Light' : SpotLight
⟐ Transform
⟐ SynchronizationComponent
⟐ SpotLightComponent
Dice used in the tutorial:
▿ '' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'dice02' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'Cube' : ModelEntity
⟐ Transform
⟐ ModelComponent
⟐ SynchronizationComponent
@@AnyoneCanCode
@@SegmenationFault I don't know anything about usdz files. How would I find out the structure of my model like you did here? I also can't get physics to apply.
@@chompskiGG hey! You just have to print it, here's my code snippet:
if let diceModel = try? await Entity(named: "cube2"),
let dice = diceModel.children[1].children.first {
print(dice)
print(diceModel)
//other code
}
which then prints
▿ 'Cube_001' : ModelEntity
⟐ Transform
⟐ ModelComponent
⟐ SynchronizationComponent
for "dice" specifically , and
▿ '' : Entity, children: 3
⟐ Transform
⟐ SynchronizationComponent
▿ 'Camera' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'Camera' : PerspectiveCamera
⟐ PerspectiveCameraComponent
⟐ Transform
⟐ SynchronizationComponent
▿ 'Cube' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'Cube_001' : ModelEntity
⟐ Transform
⟐ ModelComponent
⟐ SynchronizationComponent
▿ 'Light' : Entity, children: 1
⟐ Transform
⟐ SynchronizationComponent
▿ 'Light' : SpotLight
⟐ SpotLightComponent
⟐ Transform
⟐ SynchronizationComponent
for the original dice model. Hope that helps and let me know if you have more questions!
Great video! I did have a question. Around 24:50, when I drag the dice inwards so like vertically downwards, it falls through the floor and disappears completely. Any idea as to why this might be happening?
Thanks! That’s a great point. Since the dice can be dragged anywhere, it is possible to clip it through the ground. This may not be an issue on a physical device, since you can’t phase your hand through the ground 😅
A quick fix would be to set a minimum y-value and prevent the dice’s position from going below that value. Hope this helps!
Thanks for sharing. Curious to know how does the actual "in-headset" experience look like?
When you wear the Vision Pro, you'll be able to use hand gestures and manipulate the 3D objects directly. For example you can pinch to pick up the dice!
@@AnyoneCanCode
Understood but you have tried it yourself since I could only see from your emulator
Another question what kind of rework is required to cross deploy this into a Meta Quest headset?
👍
This tutorial is made specifically for Apple Vision Pro. If you want to deploy it to Meta as well, a game engine like Unity could be an option!
Amazing tutorial, I bought the code and material, and everything works fine on my Macbook. How can I run this app on my real Apple Vision Pro?
Thanks and congrats on getting a Vision Pro! You can connect Xcode to your Vision Pro over WiFi on the same network. If you open Remote Devices in your Vision Pro settings and go to Devices and Simulators on Xcode, you should be able to pair the device. After that, enable Developer Mode in your AVP’s settings, restart, then run the app from Xcode. Hope this helps!
Great, TY, is any app assistance to create code if we are not a deep programer like you?
Of course, there are LLMs like ChatGPT or Bard which can assist you with your code. However I strongly suggest that you don’t rely on them when learning how to code!
I am able to load 3d files into the Simulator, but how do I make it such that I can then move those 3D entities around? My 3D files do not load with the white bar underneath like yours. Please advise!
Hi! This tutorial explains how you can make the object interactive and drag it around. Unlike windows, there won’t be a white bar below the object, but instead you can just click and drag on the object itself. Hope this helps!
Hey, is it a method to scale/movve an attachment/3d object when I hovered it with the eyes? I tried with HoverEffect with lift but it only highlights the object for everything I tried.
Hey, there is no option to track eye movements in VisionOS due to security reasons
Hi! I can confirm that eye tracking on VisionOS isn’t available, exactly as what Daniel mentioned.
Exceptional tutorial! Get a quieter keyboard though! :D
Hi sir, just want to know if buying a Vision Pro is going to allow me to build and test Vision Pro applications?
On Apple website, it says need a Vision Pro development kit. Thanks a lot
Hi! Any Vision Pro will work with testing your apps. I’d recommend using the regular Vision Pro since you can connect over WiFi!
On minute 19:36, my dice doesn't fall. I've checked the code several times and seems identical. Not sure if anything has changed since the video. I've also restarted XCode and the simulator but no luck :( do you know what's the issue? Maybe someone else has had this issue?
Hi! This could be because you haven’t set the dice’s physics body to dynamic. Other than this, it is difficult to know what the issue is, so I would recommend making sure there’s no typos!
is it possible to just get direct access to the left-eye and right-eye screens, to port an app that is already vr-capable?
Hi! Are you trying to write directly to the screen? If so, I don’t believe that is possible at the moment. A hacky work-around may be to place head-locked content in front of the user and render your VR content onto there. Otherwise, you can always create an immersive space and add your VR content there! Hope this helps!
I am trying to make another app using some lessons from this video, but I've run into a problem. When I do the variables similar to your "diceData" the variables only change within their respective files. So if I change, for example, "rolledNumber" in the ImmersiveView it will only change there and the variable will be unchanged in the ContentView.
I have "ImmersiveView(spaceData: SpaceData())" in the App file and "var spaceData: SpaceData" in both the ImmersiveView and ContentView. Is there any thing I can try or test to make this work?
When you write “ImmersiveView(spaceData: SpaceData())”, the brackets “()” after SpaceData will create a new instance of the data, which means that it won’t update the data across your files. You should reference your “spaceData” variable instead, which should solve the issue. Hope this helps!
@@AnyoneCanCode I actually got it working with an ObservableObject but thank you for the detailed response. Is there anyway to add walls or use the users house (ARKit?) so the objects don't roll forever?
Do you need to be granted an VisionOS devloper kit to actually create apps?
You don’t need to! You can use the simulator to test your app and then publish it. Of course, you can request to have your app reviewed on a physical Vision Pro, or apply to go to a developer lab (if you’re near one) to try it out yourself!
Pro Tip: once project is complete copy all code and paste in VS Code code pilot and have it explain the code line by line to gain deeper insights into concepts, code and frameworks.
hello, do you mean github copilot chat?
I have a idea really 2 different ideas that would have most likely similar coding for the app ... Could I pay you to make a app for me ?
Can I start to create on Windows system?
Unfortunately, Xcode is only available on Macs.
No
Nice hat.
Dang Homie!!!
you went missing for a while
I’ve been busy with my other projects 😄
16:40 How you know those functions?
Apple’s documentation is a good resource to know what functions to use! Xcode also has autocomplete which gives you a good hint as to what to use.
Because this is marketed as a beginner tutorial, you need to slow down and explain each step and function more. I basically just copied your code, but I didn't understand what I was doing and I'm gonna have trouble recreating it.
This is a beginner tutorial for those who are new to VisionOS development, and there is some required basic knowledge of Swift. I’m trying to strike a balance between keeping the videos short and adding depth to the tutorial! I’ll keep this in mind if I create a more beginner-friendly video. Thanks!