I facing to many lags in pubgmobile when i m playing its not running properly
GameplayKit
RSS for tagArchitect and organize your game logic and incorporate common gameplay behaviors in your app using GameplayKit.
Posts under GameplayKit tag
9 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hi there,
With a couple of other developers we have been busy with migrating our SpriteKit games and frameworks to Swift 6.
There is one issue we are unable to resolve, and this involves the interaction between SpriteKit and GameplayKit.
There is a very small demo repo created that clearly demonstrates the issue. It can be found here:
https://github.com/AchrafKassioui/GameplayKitExplorer/blob/main/GameplayKitExplorer/Basic.swift
The relevant code also pasted here:
import SwiftUI
import SpriteKit
struct BasicView: View {
var body: some View {
SpriteView(scene: BasicScene())
.ignoresSafeArea()
}
}
#Preview {
BasicView()
}
class BasicScene: SKScene {
override func didMove(to view: SKView) {
size = view.bounds.size
anchorPoint = CGPoint(x: 0.5, y: 0.5)
backgroundColor = .gray
view.isMultipleTouchEnabled = true
let entity = BasicEntity(color: .systemYellow, size: CGSize(width: 100, height: 100))
if let renderComponent = entity.component(ofType: BasicRenderComponent.self) {
addChild(renderComponent.sprite)
}
}
}
@MainActor
class BasicEntity: GKEntity {
init(color: SKColor, size: CGSize) {
super.init()
let renderComponent = BasicRenderComponent(color: color, size: size)
addComponent(renderComponent)
let animationComponent = BasicAnimationComponent()
addComponent(animationComponent)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
@MainActor
class BasicRenderComponent: GKComponent {
let sprite: SKSpriteNode
init(color: SKColor, size: CGSize) {
self.sprite = SKSpriteNode(texture: nil, color: color, size: size)
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class BasicAnimationComponent: GKComponent {
let action1 = SKAction.scale(to: 1.3, duration: 0.07)
let action2 = SKAction.scale(to: 1, duration: 0.15)
override init() {
super.init()
}
override func didAddToEntity() {
if let renderComponent = entity?.component(ofType: BasicRenderComponent.self) {
renderComponent.sprite.run(SKAction.repeatForever(SKAction.sequence([action1, action2])))
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
As SKNode is designed to run on the MainActor, the BasicRenderComponent is attributed with MainActor as well. This is needed as this GKComponent is dedicated to encapsulate the node that is rendered to the scene.
There is also a BasicAnimationComponent, this GKComponent is responsible for animating the rendered node.
Obviously, this is just an example, but when using GameplayKit in combination with SpriteKit it is very common that a GKComponent instance manipulates an SKNode referenced from another GKComponent instance, often done via open func update(deltaTime seconds: TimeInterval) or as in this example, inside didAddToEntity.
Now, the problem is that in the above example (but the same goes foupdate(deltaTime seconds: TimeInterval) the methoddidAddToEntity is not isolated to the MainActor, as GKComponent is not either.
This leads to the error Call to main actor-isolated instance method 'run' in a synchronous nonisolated context, as indeed the compiler can not infer that didAddToEntity is isolated to the MainActor.
Marking BasicAnimationComponent as @MainActor does not help, as this isolation is not propogated back to the superclass inherited methods.
In fact, we tried a plethora of other options, but none resolved this issue.
How should we proceed with this? As of now, this is really holding us back migrating to Swift 6. Hope someone is able to help out here!
Hello, I'm writing to report an issue (or a documentation error).
I am using the Entity/Component Architecture incorporated in the GamePlayKit framework. Additionally, I want to take advantage of the user interface provided by the Scene Editor. This is essential for me if I want to involve more people in the project.
The issue occurs when linking the user interface data with the GKScene of the aforementioned framework.
The first issue arises when adding a component through the interface as shown in the image
Then at that moment:
if let scene = GKScene(fileNamed: "GameScene") {
// Get the SKScene from the loaded GKScene
if let sceneNode = scene.rootNode as! GameScene? {
Scene.rootNode is nil, and the scene is not presented.
However, I can work around this issue by initializing the scene separately:
if let scene = GKScene(fileNamed: "GameScene") {
// Get the SKScene loaded separately
if let sceneNode = SKScene(fileNamed: "GameScene") as! GameScene? {
But from here, two issues arise:
The node contains a component, and the scene has been loaded separately
When trying to access a specific entity through its SKSpriteNode:
self.node?.entity // Is nil
It becomes very difficult to access a specific entity. When adding a component, an entity is automatically created. This is demonstrated here:
The node contains a component, and the scene has been loaded separately.
I only have one way to access this entity, and since there is only one, it's easy:
sceneNode.entities[0]
But even so, it's not very useful because when I try to access its components, it turns out they don't exist.
I just wanted to mention this because it would be very helpful for me if this issue could be resolved.
Thank you very much in advance.
Hello,
I’m playing around with making an fully immersive multiplayer, air to air dogfighting game, but I’m having trouble figuring out how to attach a camera to an entity.
I have a plane that’s controlled with a GamePad. And I want the camera’s position to be pinned to that entity as it moves about space, while maintaining the users ability to look around.
Is this possible?
--
From my understanding, the current state of SceneKit, ARKit, and RealityKit is a bit confusing with what can and can not be done.
SceneKit
Full control of the camera
Not sure if it can use RealityKits ECS system.
2D Window. - Missing full immersion.
ARKit
Full control of the camera* - but only for non Vision Pro devices. Since Vision OS doesn't have a ARView.
Has RealityKits ECS system
2D Window. - Missing full immersion.
RealityKit
Camera is pinned to the device's position and orientation
Has RealityKits ECS system
Allows full immersion
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.
Hello,
I'm building apps for iPhone and iPad.
Those are working together like a 2-screen Nintendo switch.
Is there any way for communication between iPhone and iPad without an outside server?
PAN(personal area network) could be a solution, but I could not find any information to use it for my case.
If the iPad is connected to iPhone as a personal hotspot (though there's no cell tower), they should be communicate each other. I think there's a better way for my case.
Could anyone can tell me where I start to looking for?
Thanks,
JJ
I was trying update gptk, so i removed the old one ( installed by Xcode 15.0 ) and reinstalled it, but accuired a issue:
Error: apple/apple/game-porting-toolkit 1.1 did not build
Logs:
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/00.options.out
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/01.configure
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/01.configure.cc
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/02.make
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/wine64-build
If reporting this issue please do so to (not Homebrew/brew or Homebrew/homebrew-core):
apple/apple
Error: Your Xcode (15.0) is outdated.
Please update to Xcode 15.4 (or delete it).
Xcode can be updated from the App Store.
So I upgrade the Xcode to 15.4 by app store and still encountered:
Error: apple/apple/game-porting-toolkit 1.1 did not build
Logs:
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/00.options.out
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/01.configure
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/01.configure.cc
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/02.make
/Users/CASEM/Library/Logs/Homebrew/game-porting-toolkit/wine64-build
If reporting this issue please do so to (not Homebrew/brew or Homebrew/homebrew-core):
apple/apple
I've been reading some post says use 15.1, but still get same error report.
What should I do next?
Any help woulbe appreciated.
when i installed Game porting toolkit 1.1, i got an error such as below:
error: assignment to 'DWORD64' {aka 'long long unsigned int'} from 'PVOID' {aka 'void *'} makes integer from pointer without a cast [-Wint-conversion]
anybody who knows how to solve it
My MacBook Pro is M3 max, running macOS 14.4.1 (23E224), with Xcode 15.3 and Command_Line_Tools_for_Xcode_15.3 installed. When I tried to execute "brew -v install apple/apple/game-porting-toolkit", it reported the following error.
Error: apple/apple/game-porting-toolkit 1.1 did not build
Logs:
/Users/yuanmouren/Library/Logs/Homebrew/game-porting-toolkit/00.options.out
/Users/yuanmouren/Library/Logs/Homebrew/game-porting-toolkit/01.configure
/Users/yuanmouren/Library/Logs/Homebrew/game-porting-toolkit/01.configure.cc
/Users/yuanmouren/Library/Logs/Homebrew/game-porting-toolkit/02.make
/Users/yuanmouren/Library/Logs/Homebrew/game-porting-toolkit/wine64-build
If reporting this issue please do so to (not Homebrew/brew or Homebrew/homebrew-core):
apple/apple
I found the following error reasons in the console.
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:629:11: error: unknown type name 'SecTrustSettingsDomain'
const SecTrustSettingsDomain domains[] = {
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:630:9: error: use of undeclared identifier 'kSecTrustSettingsDomainSystem'
kSecTrustSettingsDomainSystem,
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:631:9: error: use of undeclared identifier 'kSecTrustSettingsDomainAdmin'
kSecTrustSettingsDomainAdmin,
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:632:9: error: use of undeclared identifier 'kSecTrustSettingsDomainUser'
kSecTrustSettingsDomainUser
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:640:18: warning: this function declaration is not a prototype [-Wstrict-prototypes]
status = SecTrustSettingsCopyCertificates(domains[domain], &certs);
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:641:23: error: use of undeclared identifier 'noErr'
if (status == noErr)
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:647:31: warning: this function declaration is not a prototype [-Wstrict-prototypes]
if ((status = SecItemExport(cert, kSecFormatX509Cert, 0, NULL, &certData)) == noErr)
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:647:51: error: use of undeclared identifier 'kSecFormatX509Cert'
if ((status = SecItemExport(cert, kSecFormatX509Cert, 0, NULL, &certData)) == noErr)
^
/private/tmp/game-porting-toolkit-20240414-2133-st99bv/wine/dlls/crypt32/unixlib.c:647:95: error: use of undeclared identifier 'noErr'
if ((status = SecItemExport(cert, kSecFormatX509Cert, 0, NULL, &certData)) == noErr)
^
2 warnings and 7 errors generated.
make: *** [dlls/crypt32/unixlib.o] Error 1
make: *** Waiting for unfinished jobs....
How should I resolve this issue?