Post

Replies

Boosts

Views

Activity

Entity not returning to original position
Hello, I am making a RealityKit app where a ball goes and hits some stones, and then goes back to its original position. However, in moving back the ball always tilts a little and sometimes even goes backwards or in other directions! I add my entities in these lines of code: stoneEntity!.scale = [5, 5, 5] anchor.addChild(stoneEntity!) stoneEntity!.transform.translation = SIMD3<Float>(anchor.position.x, anchor.position.y, anchor.position.z) stoneX = stoneEntity!.position.x stoneY = stoneEntity!.position.y stoneZ = stoneEntity!.position.z stoneEntity?.generateCollisionShapes(recursive: true) // Add ball entity anchor.addChild(ballEntity) ballEntity.transform.translation = SIMD3<Float>(anchor.position.x, anchor.position.y, anchor.position.z + 1) ballEntity.generateCollisionShapes(recursive: true) ballEntity.physicsBody = PhysicsBodyComponent(massProperties: PhysicsMassProperties.default, material: PhysicsMaterialResource.default, mode: .kinematic) ballEntity.collision = CollisionComponent(shapes: [.generateSphere(radius: 0.1)], mode: .default, filter: .default) ballEntity.physicsBody?.isTranslationLocked = (true, true, false) view.scene.addAnchor(anchor) And move my ball back in the code: ballEntity.transform.translation = SIMD3<Float>(0, 0, 1) If anyone has any ideas please could you let me know ASAP? Thank you!
1
0
588
Feb ’24
SwiftUI Background Color not Working
Hi. I am making an app with a background image, but that does not take up the full screen on Pro Max iPhones, so I am setting a background color behind the image. Surprisingly, the background color is not showing up. Here is the code of the View: struct IntroView: View {     @StateObject var viewRouter: ViewRouter     var body: some View {         ZStack {             Color("AccentColor").edgesIgnoringSafeArea(.all)             Image("GameStart")             VStack {                 Text(""" The NS Labs app is a placeholder to not show confidential app name """                 ).font(.system(size: 20)).frame(width: UIScreen.screenWidth, height: 250).foregroundColor(Color(.systemBlue)) Text(""" Welcome to the NS Labs App """ ).font(.system(size: 20)).frame(width: UIScreen.screenWidth, height: 200).foregroundColor(Color(.systemBlue))                 Text("Click Let’s Go to start using the NS Labs app!").font(.system(size: 20)).frame(width: UIScreen.screenWidth, height: 200).foregroundColor(Color(.systemYellow)).padding(.bottom, 20)                 Button(action: {                     viewRouter.currentPage = .page2                 }) {                     Text("Let's Go!").foregroundColor(.white).font(.system(size: 34)) }.frame(width: 200, height: 70).background(Color.yellow).cornerRadius(12)             }         } } }
1
0
1.4k
Oct ’21
Multi-View App
Hi. I am trying to make an app to control a robot. The app will be entirely SwiftUI and will have a structure like this: Connect button View-Home Screen ---Games Mode ---Drive Mode ---Code Lab How will I make the navigation? I have made the views already but don't know how to use navigation in SwiftUI.
0
0
727
Feb ’21
Redirect to view after button clicked
Hi! I am making an app where you connect to the device and then it takes you to a Device Home view. I have gotten the connection to work, but how can I redirect to the Device Home view? Here is the SwiftUI code for the button: swift Button(action: { let clientID = "Momo-iOS-"+String(Int.random(in: 0..100)) let mqtt = CocoaMQTT(clientID: clientID, host: "192.168.1.26") mqtt.connect() }) { ZStack { RoundedRectangle(cornerRadius: 100).fill(Color.yellow).frame(width: 240, height: 80)   Text("Connect").font(.system(size: 26)).foregroundColor(.white)   } }
0
0
724
Feb ’21
How should I use ObservableObject
Hi Devs! I have my Firestore database set up and I want to have a reusable SwiftUI view for it. I asked a question about this and someone said use ObservableObject. I surfed the web and could not find any tutorials. I would like it so my view's title changes to a value from the database. This is the code to read the database: let docRef = db.collection("houses").document("\(houseId)")   docRef.getDocument { (document, error) in             if let document = document, document.exists {                 let dataDescription = document.data().map(String.init(describing:)) ?? "nil"                 print("Document data: \(dataDescription)")                 self.title = dataDescription                          } else {                 print("Document does not exist")             } } How can I make dataDescription the text of a label?
1
0
639
Dec ’20
SwiftUI with Database
Hi! I have a Cloud Firestore database set up and I am trying to make a SwiftUI view which grabs data from houseId(a key in the database) and puts it on a label. When I try, it says Type 'Void' cannot conform to 'View'; only struct/enum/class types can conform to protocols Here is my code: import SwiftUI import MapKit import Contacts import Firebase struct BirdhouseView: View {     @State private var region = MKCoordinateRegion(   center: CLLocationCoordinate2D(latitude: 25.7617, longitude: 80.1918), span: MKCoordinateSpan(latitudeDelta: 10, longitudeDelta: 10)     )     var body: some View {                  let db = Firestore.firestore()                  var houseId = "bluebirdsample"         let housesRef = db.collection("houses").document("\(houseId)")                  housesRef.getDocument { (document, error) in             if let document = document, document.exists {                 let dataDescription = document.data().map(String.init(describing:)) ?? "nil"                 print("Document data: \(dataDescription)")             } else {                 print("Document does not exist")             }         }                  ScrollView {             VStack {                 Text("Bluebird House").foregroundColor(Color.yellow).font(.system(size: 40))                 Image(uiImage: UIImage(named: "sample_house")!).resizable().frame(width: 290, height: 190, alignment: .center).padding()                 Text("A super-cute birdhouse in Irvine Terrace Park!!").padding().foregroundColor(Color.yellow)                 Divider()                 HStack {                     Image(uiImage: UIImage(named: "sample-user")!).resizable().clipShape(Circle()).frame(width: 60, height: 60)                     Text("Beep Boop").font(.system(size: 24)).bold()                 }                 Divider()                 Button(action: {                     let url = URL(string: "http://maps.apple.com/maps?saddr=&daddr=\(33.5958557),\(-117.8806124)")                     UIApplication.shared.open(url!)                 }) {                     Text("Get Directions in Maps!")                 }                                  Map(coordinateRegion: $region).frame(width: UIScreen.main.bounds.size.width, height: 400)         }     }     } } struct BirdhouseView_Previews: PreviewProvider {     static var previews: some View {         BirdhouseView()     } }
3
0
1.8k
Dec ’20
User-Generated App Clips
Hi there, How can I have user generated app clips, for example in a maps app someone adds a place in the app, an app clip gets made, and if you don't have the app, it opens a clip with the info about the place? Also if someone makes something in a building app, shares it, and whoever opens sees a clip with their creation? Like the app clip for https:// parcelapp.net Please help?
1
0
634
Nov ’20
App Clip Smart Banner
I have an app, Building Blox AR, which is "Ready for Sale", and I have added <meta name="apple-itunes-app" content="app-id=1519633347, app-clip-bundle-id=com.duckida.LegoApp.Clip> to my website. The App-ID and App-Clip-Bundle-ID are correct, but the Smart Banner does not show up unless you have iOS 13 or the app is downloaded. Also, when you send this in Messages, it just shows the URL. A QR code with the URL doesn't open the clip either. I only have a default app clip experience set up, because I am having a very hard time with Advanced Experiences. Please Help me get my banner, QR code, and Messages App Clip to work!
2
0
1k
Sep ’20