Hello,
has anyone been able to implement in their game a way to display the number of players currently online in their game?. I thought up of this feature and thought it will be useful for players to find out if there is anyone currently online so that they don't waste their time trying to find a random online match. Any help will be greatly appreciated.
Kind regards,
Jabir Abdi
Delve into the world of graphics and game development. Discuss creating stunning visuals, optimizing game mechanics, and share resources for game developers.
Post
Replies
Boosts
Views
Activity
I use quad_sum to optimize the lighting grid and shadow filter performance.
Based on Metal Feature Set Tables, Apple Family 4 should support quad group operations like quad_sum and quad_max. However, on the iPhone X and iPhone 8, during creating pipeline states, we have the following error output: Encountered unlowered function call to air.quad_sum.f32.
It works perfectly for iPhone 11 and higher versions. Should I improve my feature-checking logic from Apple Family 4 to Apple Family 5, or do I have other options to fix this unexpected behavior?
How do I set the static position of a SKSpriteNode so that it tilts toward the UIBezierPath as if it were following this Path?
When I first start my App, these Nodes are all aligned in a straight line
When I call:
var trainAction = SKAction.follow(trainPath.cgPath,
asOffset: false,
orientToPath: true,
speed: thisSpeed)
for moving the train, the train + each car will orient its tilt to hug the trainPath.
But I want the identical tilt to hug the trainPath for its initial static presentation.
How do I do that?
Is there new API for generating Indirect Commands for the Metal Shader Converter? Is there any example project? I currently use a shader to copy indirect commands. Is there a way to do that with the new Shader Converter pipeline?
This question is about USD animations playing correctly in macOS Preview but not with RealityKit on visionOS.
I have a USD file created with 3D Studio Max that contains mesh-based smoke animation:
https://drive.google.com/file/d/1L7Jophgvw0u0USSv-_0fPGuCuJtapmzo/view
(5.6 MB)
Apple's macOS 14.5 Preview app is able to play the animation correctly:
However, when a visionOS app uses RealityKit to load that same USD file in visionOS 2.0 beta 4, built with 16.0 beta 3 (16A5202i), and Entity/playAnimation is called, the animation does not play as expected:
This same app is able to successfully play animation of a hierarchy of solid objects read from a different USD file.
When I inspect the RealityKit entities loaded from the USD file, the ground plane entity is a ModelEntity, as expected, but the smoke entity type is Entity, with no associated geometry.
Why is it that macOS Preview can play the animation in the file, but RealityKit cannot?
Thank you for considering this question.
HI guys,
I'm integrating the RoomPlan framework into my app.
I'm able to scan a room and extract the nodes from the CaptureStructure object. So far, I can rebuild the 3D object in the SceneView, but I can't render the openings and the windows correctly. I'm struggling to add these two objects correctly in the wall, in order to make the wall transparent where they are supposed to be.
If I export the CaptureStructure into a usda file and then I load it directly in the SceneView, all the doors, windows and openings are correctly rendered, therefore I do believe that I'm doing something wrong.
Could you please tell me what I'm doing wrong?
I added here a screenshot of my problem:
I have also a prototype, which you can run and see the problem I'm talking about: https://github.com/renanstig/3d-scenekit-prototype
i'm trying to figure out how to basically engrave some text into this ellipsoid mesh. so far the only thing i've learned that can sort of come close to what im looking for is SCNText but it floats above the ellipsoid and doesnt conform to the angular shape.
let allocator = MTKMeshBufferAllocator(device: MTLCreateSystemDefaultDevice()!)
let disc = MDLMesh.newEllipsoid(
withRadii: vector_float3(Float(discDiameter/2), Float(discDiameter/2), Float(discThickness/2)),
radialSegments: 64,
verticalSegments: 64,
geometryType: .triangles,
inwardNormals: false,
hemisphere: false,
allocator: allocator
)
let discGeometry = SCNGeometry(mdlMesh: disc)
let material = createIridescentMaterial()
discGeometry.materials = [material]
This may be a bit dumb but I've really been having trouble with understanding the documentation for Apple's Unity Plugins. I wanted to implement Game Center functionality on my game. So far the only line of code I've managed to get working is the authentication, in which I did
async void Start()
{
await Login();
}
public async Task Login()
{
if (!GKLocalPlayer.Local.IsAuthenticated)
{
var player = await GKLocalPlayer.Authenticate();
var localPlayer = GKLocalPlayer.Local;
]
}
However, I'm at a complete loss as to how to open leaderboards. I followed the documentation given:
void OpenLeaderboard()
{
var allLeaderboards = await GKLeaderboard.LoadLeaderboards();
var filteredLeaderboards = await GKLeaderboard.LoadLeaderboards("leaderboardIwant1");
}
But it did not work. What did I do wrong? Am I missing a function to get it to work? Why can't Apple write proper documentation to properly implement this in a simple way?
My apologies for my frustration. Up until now I've used another plugin from the Unity Asset Store which is shockingly easy to use, but I decided to attempt to use Apple's system because the plugin I had used deprecated functions and I was afraid the App Store would not approve it. But Apple's own plugins are stunningly opaque and hard to test.
As additional questions (but not the main ones), I'm also completely at a loss how to submit scores or load specific leaderboards and Apple's documentation does nothing to help there either.
Any help or thoughts are appreciated. Thanks.
Hi, I was wondering if we could ever get the Game Porting Toolkit to ever translate Vulkan and Vulkan RT extensions? The reason I ask is because I would like to try something involving RTX Remix which requires Vulkan specific extensions
In the last several days I've gotten reports from customers saying that Game Center suddenly cannot connect to players. I was able to verify this myself.
It will find players to match, but then during the Connecting process it just sits there indefinitely with a spinning thing. Up until maybe 4 days ago this had worked fine for the last 12+ years, so something on the Game Center server broke.
Is anyone else experiencing the same problem?
I am trying to work out how to enable the Metal HUD on iOS for App Store games?
I am aware you can go into Developer settings and enable it… but it only appears for some games like HADES or TestFlight apps.
I know the HUD appears for sideloaded games too. With sideloadly, I’ve sideloaded GRID Autosport and Myst - per screenshots. But it’s a very time consuming process, on demand resources usually don’t download… and I’m not sure if its legal.
I tried using Xcode and Attach to Process for a game like Resident Evil 7 or just anything… but it doesn’t work.
I’ve tried restoring a backup and editing the .GlobalPreferences.plist and info.plist file with “MetalForceHudEnabled Boolean Yes”, in a new row… but nothing.
any ideas?
Hello,
I'm developing a RealityKit based app. As part of this, I would like to have a material applied to 3d objects which is essentially contains a texture which is the live camera feed from the arsession.
I have the code below which does apply a texture of the camera feed to the box but it essentially only shows the camera snapshot at the time the app loads and doesn't update continuously.
I think the issue might be that there is some issue with how the delegate is setup and captureOutput is only called when the app loads instead of every frame. Open to any other approach or insight that gets the job done.
Thank you for the help!
class CameraTextureViewController: UIViewController {
var arView: ARView!
var captureSession: AVCaptureSession!
var videoOutput: AVCaptureVideoDataOutput!
var material: UnlitMaterial?
var displayLink: CADisplayLink?
var currentPixelBuffer: CVPixelBuffer?
var device: MTLDevice!
var commandQueue: MTLCommandQueue!
var context: CIContext!
var textureCache: CVMetalTextureCache!
override func viewDidLoad() {
super.viewDidLoad()
setupARView()
setupCaptureSession()
setupMetal()
setupDisplayLink()
}
func setupARView() {
arView = ARView(frame: view.bounds)
arView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(arView)
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical]
arView.session.run(configuration)
arView.session.delegate = self
}
func setupCaptureSession() {
captureSession = AVCaptureSession()
captureSession.beginConfiguration()
guard let videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back),
let videoDeviceInput = try? AVCaptureDeviceInput(device: videoDevice),
captureSession.canAddInput(videoDeviceInput) else { return }
captureSession.addInput(videoDeviceInput)
videoOutput = AVCaptureVideoDataOutput()
videoOutput.setSampleBufferDelegate(self, queue: DispatchQueue(label: "cameraQueue"))
videoOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32BGRA]
guard captureSession.canAddOutput(videoOutput) else { return }
captureSession.addOutput(videoOutput)
captureSession.commitConfiguration()
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
self?.captureSession.startRunning()
}
}
func setupMetal() {
device = MTLCreateSystemDefaultDevice()
commandQueue = device.makeCommandQueue()
context = CIContext(mtlDevice: device)
CVMetalTextureCacheCreate(nil, nil, device, nil, &textureCache)
}
func setupDisplayLink() {
displayLink = CADisplayLink(target: self, selector: #selector(updateFrame))
displayLink?.preferredFrameRateRange = CAFrameRateRange(minimum: 60, maximum: 60, preferred: 60)
displayLink?.add(to: .main, forMode: .default)
}
@objc func updateFrame() {
guard let pixelBuffer = currentPixelBuffer else { return }
updateMaterial(with: pixelBuffer)
}
func updateMaterial(with pixelBuffer: CVPixelBuffer) {
let ciImage = CIImage(cvPixelBuffer: pixelBuffer)
var tempPixelBuffer: CVPixelBuffer?
let attrs = [
kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue,
kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue,
kCVPixelBufferMetalCompatibilityKey: kCFBooleanTrue
] as CFDictionary
CVPixelBufferCreate(kCFAllocatorDefault, CVPixelBufferGetWidth(pixelBuffer), CVPixelBufferGetHeight(pixelBuffer), kCVPixelFormatType_32BGRA, attrs, &tempPixelBuffer)
guard let tempPixelBuffer = tempPixelBuffer else { return }
context.render(ciImage, to: tempPixelBuffer)
var textureRef: CVMetalTexture?
let width = CVPixelBufferGetWidth(tempPixelBuffer)
let height = CVPixelBufferGetHeight(tempPixelBuffer)
CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, textureCache, tempPixelBuffer, nil, .bgra8Unorm, width, height, 0, &textureRef)
guard let metalTexture = CVMetalTextureGetTexture(textureRef!) else { return }
let ciImageFromTexture = CIImage(mtlTexture: metalTexture, options: nil)!
guard let cgImage = context.createCGImage(ciImageFromTexture, from: ciImageFromTexture.extent) else { return }
guard let textureResource = try? TextureResource.generate(from: cgImage, options: .init(semantic: .color)) else { return }
if material == nil {
material = UnlitMaterial()
}
material?.baseColor = .texture(textureResource)
guard let modelEntity = arView.scene.anchors.first?.children.first as? ModelEntity else {
let mesh = MeshResource.generateBox(size: 0.2)
let modelEntity = ModelEntity(mesh: mesh, materials: [material!])
let anchor = AnchorEntity(world: [0, 0, -0.5])
anchor.addChild(modelEntity)
arView.scene.anchors.append(anchor)
return
}
modelEntity.model?.materials = [material!]
}
}
extension CameraTextureViewController: AVCaptureVideoDataOutputSampleBufferDelegate {
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
currentPixelBuffer = pixelBuffer
}
}
extension CameraTextureViewController: ARSessionDelegate {
func session(_ session: ARSession, didUpdate frame: ARFrame) {
// Handle AR frame updates if necessary
}
}
Hi I'm working on a project that uses RealityKit including the placement of 3d objects.
However, I want to be able to run the background camera through Metal post-processing before being rendered but haven't been able to find a working approach. I'm open to it rendering directly into the ARview or a separate MTKview or swiftui layer.
I've tried using the default xcode project of an Augmented Reality App with Metal Content. However it seems to use a 1.33 aspect camera by default instead of the iphone 15s standard ratio which works by default when I use the regular realitykit pathway and doesnt seem to have the proper ratio available as an option
Open to any approach that gets the job done here.
Thank you,
Any direction would be
How to overlay an image in RealityKit on a 3D model using code so that it does not stretch to the entire object, but has its own height and width that I can change?
I have a solution on how to do this, but then it will not be possible to change the height, width or place it anywhere on the 3D model. And this is to cut out a part of the object and overlay the image on the entire cutout area. How to overlay a 2D image on a 3D model without stretching the photo to the entire 3D object?
If this is possible, please give an example of how to do this in code. I could not find on the Internet how to do this. Although in other engines this can be done, for example, in Blender or Unity. If I am not mistaken, this is done there using decals
I noticed that with the 4th betas of iOS 18 and visionOS 2, some USDZ models' texture mapping looks completely broken. The issue occurs only with a device, not with the Simulator. It's a regression, the models look fine with iOS 17.5.1 and visionOS 1.2.
The issue occurs if I load a model as an Entity in a RealityView iOS or visionOS, or in a SwiftUI 3DModel view on visionOS.
Has anyone seen this too? Is there a workaround?
I filed a bug report with a minimal example project, it's FB14473756.
Screenshot on Vision Pro device:
Screenshot on Vision Pro Simulator:
Has anyone gotten EnvironmentLightingConfigurationComponent to work?
I tried the code from https://developer.apple.com/documentation/realitykit/environmentlightingconfigurationcomponent to prevent a planet from being lit by the environment. My goal is that the side that isn't lit by the star appears pitch black. However, the code seems to have no effect on visionOS 2 and iPadOS 18 (I tried betas 1 through 4, on device, built with Xcode 16 beta 4).
No matter if there is a PointLight or no light at all in the scene, no matter if I use SimpleMaterial or PhysicallyBasedMaterial, no matter if I use a texture or a color on the sphere.
I filed a bug report, it's FB14470954.
Or am I doing something wrong? Here's my code:
var material = PhysicallyBasedMaterial()
if let tex = try? await TextureResource(named: "planet.jpg")
{
material.baseColor = .init(texture: .init(tex))
material.emissiveIntensity = 0
let sphereMesh = MeshResource.generateSphere(radius: 0.5)
let entity = ModelEntity()
entity.components.set(ModelComponent(mesh: sphereMesh, materials: [material]))
entity.position = [-1, 1.0, -1.0]
let envLightingConfig = EnvironmentLightingConfigurationComponent(environmentLightingWeight: 0)
entity.components.set(envLightingConfig)
content.add(entity)
}
I have been using the iOS 18 public beta on my iPhone XR for the past 3-4 days, and I frequently play a popular competitive game called “Free Fire.” I’ve noticed an issue while playing the game. Whenever I switch the game to the background for any reason, such as using another app or attending an incoming call, the game’s sound does not come back when I switch back to it. No matter what I do—whether switching the phone to silent mode and then back to normal or adjusting the volume—the sound won’t return. I have to restart the game, which is frustrating since I play this game a lot. I understand that this is a beta version, and some problems are expected, but I wanted to mention this issue here in case it can be resolved.
and i also tried some stuff like reinstalling the game or restrting the device or checking for new updates and all the small stuff that would fix this but nahhhh none of them worked 😅
The TabletopKit sample app builds fine with Xcode 16 beta 1.
https://developer.apple.com/documentation/tabletopkit/tabletopkitsample
I updated to the new beta 4 and downloaded an updated version of the Tabletopkit sample code but am now getting this error.
Tabeletopkit Sample 1 issue
SwiftUI.ToolbarContent:3:51
Main actor-isolated static method '_makeContent(content:inputs:resolved:)' cannot be used to satisfy nonisolated protocol requirement
Add '@preconcurrency' to the 'ToolbarContent' conformance to defer isolation checking to run time
'_makeContent(content:inputs:resolved:)' declared here
If I go back to beta 1 it still builds OK. I tried its suggestion but it still won't build.
Is there a workaround? I didn't see it listed.
Hello,
Asking the following as, I was unable to find answers via search on the forum and in the documentation:
Invitations sent via iMessage seem to work correctly with my custom image ( GKMessageImage.png ) however, notifications sent to Game Center Friends via invites generated in Game Center do not include the custom image ( GKMessageImage.png ).
Questions:
Is this expected behavior? Is there a different way to customize the image in the notification? Note the Game Center notification includes the App name correctly.
I also noted in the WWDC session in 2016 ( saw video recently ) that there was some mention of no longer adding friends via Game Center. Is that currently true?
Thanks in advance.
Can you set isPaused = true of a SKSpriteNode and keep its SKEmitterNode still moving?