SCNAction refresh rate - apple-watch

I'm currently trying to develop a little game on Apple Watch using SceneKit.
This is a simple 2D game, with geometric shapes I tesselate.
Here is my problem. I use SCNAction to move my objects across the scene, and I don't know why, but even if the SCNScene showStatistics show me the scene runs at 60 FPS and I can see that the CPU does very little, every SCNAction is updated every half-second or so.
It's very annoying because my animations aren't smooth at all and it hurts gameplay.
Does anyone already had had this kind of problem? I've spent too much time trying to find where something went wrong and I can't find it. Is there some kind of refresh rate property on SCNAction?
Thank you in advance for the time you'll give to my case. :)

Related

Unity Animator Checking Too Slow

I'm currently just trying to learn to use the animator within Unity, I'm very in-exp at animation and don't understand it even in the editor as I focus on programming/scripting.
I have an animation and the states for the animations as-well as the conditions all working perfectly however the animation check for the next state is way to slow. I've tried changing the speed of the actual state but it speeds the animation up and makes it look like my character is walking insanely fast.
I've tried messing around with the frames, making them over a longer time period and making the speed of the state faster however it seems to counter act each other, when I make it longer frames the pace of the animation is slow and then when I make the speed of the state go quicker it just makes the frames tick faster making the animation faster.
What I believe is happening is that the check for the next state of animation is happening once the full animation has been played. However what I need is the check to be happening constantly (as if frame by frame of the unity game not the animation).
Any advice would be great, I've tried using youtube to solve this before coming here however most people are creating a platformer game where as I'm trying to aim for a top down 2d, all directional character movement instead of the linear x axis character movement., and outside libraries.
I deeply apologise for my inability to find a suitable source. I have literally just came across an article online that came across a simple solution.
here:https://answers.unity.com/questions/221601/slow-animation-response.html
basically if you can't be bothered to click the link and you are having the same problem,
find exit-time by clicking the transition and then in the inspector and untick it.
Sorry.

Monitor movement on a real world track controls Unity Camera

I am working, or about to be working, on a project where I would like to move a monitor along a railed track, left to right and vice versa, and have the camera in Unity update its movement left or right to follow the track movement. I am attempting to do something like this Video Example but on a smaller scale, and have, at certain points along the track, triggers that will spawn different animations based on where on the track the monitor is, sort of like a timeline.
I guess my question is, does anyone have any thoughts or ideas on how this is accomplished? My initial thought is using a accelerometer to get movement data and use that with some scripting to control the camera, but I am not sure how big a factor the potential error may be with this approach. Another idea would be to use some sort of Laser Range Finder to get a constant distance strapped to the back of the monitor or the track, right now I am really just brainstorming.
On the unity side of things I will be fine, I am just wondering if there are other ways, or if people may have other ideas on how this is done, before I jump into spending money on trial and error modes. Thanks for any insight that anyone may be able to offer in advanced!

How to ensure sprites face the correct direction at all times in a 2D top down game. (logic)

I am making a multiplayer top down 2D game with 3d elements. All my movement, healthbars and basic functionality is working flawlessly even while hosted and playing on a server, node.js socket.io. However In this game it is possible to move the camera like in Realm of the mad god.
in case you are in doubt here is a video: https://youtu.be/4tdcxl3aZ0c?t=31s
This of course means that the players can end up being upside down with regards to each other and I cannot find a solution that works in all regards to make sure the sprites of the other players are always facing the correct direction with regards to their movement.
I have made several solution to this problem which cover most scenarios but while play testing other things we always end up noticing that the sprites sometimes face the wrong directions. So I am wondering if anyone has an answer, the logic, the fixing this problem.
Things I have tried:
Adding a gameobject to the camera to which all sprites asses their change in distance and determine their facing direction based off that information. (this leads to the players sometimes flipping erratically when the camera is moved and they as well are moving as sometimes they may be moving slower and there although moving left the camera approaches from the right and that flips them)
Adding a gameobject to the world which allows all sprites to have a fixed point to which they can measure their change in distance and therefore also know what direction to face (this worked somewhat better as they always know what direction they have to face, however once the player is upside down everything is inverted)
Emitting to the other players wether I am upside down or not in order to try to reinvert the above solution in the case I am upside down. (I could not find a good way to do this, and it got me thinking that this must be a problem people have fixed before many times and perhaps someone know of a good solution that works.)
thank you all for your input.
I seem to have found a solution for this issue that works decently well. Keeping in mind that I do not want to have the server being involved in this and I would rather have each individual sprite know its direction rather that have something heavy trying to determine this logic I came up with the following solution. May not be the best but it works. Still very keen to hear other solutions.
On my main character I have a switch case, which changes depending on the players rotation in the world. I need this switch case anyway for fixing (http://answers.unity3d.com/questions/1348301/trying-to-change-the-cameratransparencysortaxis-to.html?childToView=1348316#answer-1348316) that issue.
As the cases change I simply place the gameobject that I want the sprites to compare their distance to at 1 of 4 positions. YPos, YNeg, XPos, XNeg. Meaning that the sprite now determines its facing direction based on a gameobject that is placed in accordance with the Players position. without having to place it on the camera.
I will update if during further play tests this gives me trouble but thus far it works in the all the cases I need it to.
Still very willing to hear other solutions to this problem.
Thank you.

High CPU use in SpriteKit game

I'm making my first game with Swift and SpriteKit and have noticed that my game quickly approaches 100% CPU use. I have been posting a lot about this recently, but here I'm now I'm now attempting to pull it apart to determine where my problems are. I originally thought my problem was with instantiating new enemies, so I removed everything but the small user-controlled spaceship and its shooting functionality. However, I'm still hitting 100% after a couple minutes of "play". I'm using the time-profiler instrument to try and figure out whats going on but I'm having trouble. I've broken up the time line:
Here is the first subgraph when the user clicks a homeScene button to enter the GameScene.
I'm not entirely sure what the red and yellow "Heaviest backtraces" with 3256x and 861x respectively mean, but from tutorials I've seen I would imagine that they are abnormally high. Here is the Call Tree as well:
I'm also not entirely sure why the controller textures would be using so much as they are simply setting two textures in the file right before the GameScene class:
let controllerBaseTexture = SKTextureAtlas(named:"Sprites").textureNamed("controllerBase")
let controllerHandleTexture = SKTextureAtlas(named:"Sprites").textureNamed("controllerHandle")
class GameScene: SKScene, SKPhysicsContactDelegate {
Then here is the Call Tree when the game starts and when the CPU reaches 100%:
I'm also confused about what "UnsaveMutableAddressors" are, as I see them very commonly when trying to debug this code.
I know this is a lot, but I'm not sure where to begin. Any suggestions would be awesome. I would also like to know if there are good resources on how to interpret this better because I've gone through a handful and I'm still very stuck.
Thanks for any help!
The profiler shows it's something in your update method for your gameScene. Keep in mind this gets ran around 60 times per second so you don't want to do anything extremely heavy there.

How to "render" a Box2D scene on iPhone

I'm currently using box2d with cocos2d on iPhone. I have quite a complex scene set up, and I want the end user to be able to record it as video as part of the app. I have implemented a recorder using the AVAssetWriter etc. and have managed to get it recording frames grabbed from OpenGL pixel data.
However, this video recording seems to a) slow down the app a bit, but more importantly b) only record a few frames per second at best.
This led me to the idea of rendering a Box2D scene, manually firing ticks and grabbing an image every tick. However, dt could be an issue here.
Just wondering if anyone has already done this, or if anyone has any better ideas?
A good solution I guess would be to use a screen recorder solution like ScreenFlow or similar...
I think your box2d is a good idea... however, you would want to used a fixed-time step. if you use dt the steps in the physics simulation will be to big, and box2d will be unstable and jittery.
http://gafferongames.com/game-physics/fix-your-timestep/
The frame rate will take a hit, but you'll get every frame. I don't think you'll be able to record every frame and still maintain a steady frame rate - that seems to be asking a lot of the hardware.