SceneKit animation issue

Hello guys.

I can’t get animations in SceneKit work correct. I’d like to build a beautiful game in 3D but I get stuck with a very simple and basic thing like animation :-(

I saw WWDC 2015 session 606 and was very impressed and start to build my game using sample code from Fox project (https://developer.apple.com/library/ios/samplecode/Fox/Introduction/Intro.html)


Steps I’ve made:

1. created a cube in 3d tool (Cheetah 3d) and export it in cube.dae

2. create skeletal animation (just a simple rotation) for cube and export only skeleton without mesh in cubeAnimation.dae

3. copy cube.dae and cubeAnimation.dae into Xcode project and convert them in cube.scn and cubeAnimation.scn

4. using Apple sample code add cube.scn on a scene

5. using Apple sample code add cubeAnimation.scn animation to cube.scn

6. build and run project ––> cube.scn is rotating BUT cube.scn resets it’s initial position to one that is in cubeAnimation.scn


Thinking that my 3d tool (Cheetah 3d) export in Collada with some issues I’ve tried to use models created by other developers but result was the same. I’ve tried to use Autodesk Maya to export animations but result was the same. I even tried to use model from Unreal Engine example (https://wiki.unrealengine.com/File:ThirdPerson_FBX.zip) but result was the same.


I put Xcode project source here https://www.dropbox.com/s/8vtmem4jqnetmwd/XcodeProject.zip?dl=0

I put models and animations source here https://www.dropbox.com/s/qkkbfhk7wrz4r4z/ModelsAndAnimations.zip?dl=0


Maybe there are some special Collada export settings to make animations work correct?

Are you creating an iphone or mac game?

Because the answer is different depending.

I've actually spent some hours since you asked the original question working on this problem and the code and models I gave you should work perfectly in iOS 9 at the very least. As they came directly from somethng I'm working on that does work. However, getting it to work in mac is a different story. You can convert your main model to scn. but... getting the animation to work is an upside down nightmare. If you convert your animtion file in to scn format it stops working though this code below gets a zombie walking on my screen on mac if I leave the animation file in dae format.

You can fill in your own file names, but in this case I have a model, it's <spoiler alert> a zombie. I have converted it to scn format (with it's skeleton in tact). I have a walk animation. That I leave in dae. It's only the skeleton.

I use this code:

-(void)walk
{
  
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"art.scnassets/Zombie_walk" withExtension:@"dae"];
    SCNSceneSource *sceneSource = [SCNSceneSource sceneSourceWithURL:url options:nil];
  
    CAAnimation *walk = [sceneSource entryWithIdentifier:@"Zombie_walk-1" withClass:CAAnimation.class];/
    SCNNode * zombie = [self.gameView.scene.rootNode childNodeWithName:@"MainZombie" recursively:YES];
    zombie.rotation = SCNVector4Make(1, 0, 0, degreesToRadian(90));//My model was off by 90 but the animation isn't.. another mac only bug.
    walk.repeatCount = INFINITY;
    walk.speed = 2/1.3;
    [zombie addAnimation:walk forKey:@"Walk"];
}


If you want my opinion and I'm sure you don't. Scenekit on mac is bugged out beyond serious consideration for the engine of a product you intend to make money from. Because of the problems you are describing It sounds like it's a mac program. As I said, the code I gave you before with the models works beautifully on iOS.

All of my mac versions of games I'm working on have been scrapped due to the unusability of scnenkit on mac. It's really sad but until scenekit is reliable, or ever managible I have to stick with ios only.

Yes to all the above.


Scene Kit is not even in alpha state.


It's best to think of it as a demonstration of intent.


That's about the state of development it and its supporting frameworks are in.


My supposition is that Apple's heading into the game production business, and that far more refined and defined versions of these "engines" are in use somewhere within Apple's new publishng empire, by those attempting to make games with their lead developers assisting them, but that there's not enough staff to fork back these (much more) developed versions of game frameworks to the general public without the kinds of secrecy and obfuscation Apple loves.


So we get the old demo versions with some infrequent, minor bugs being given attention.


The number of people (in the wild) using SK and SCN is far closer to zero than any significant number.

I guess it's not the export settings issue. Your steps 4 to 6 are unclear. It seems that you are setting the node's position. However, if the node runs a animation, this attempt will fail because the animation is controlling the node's transformation. So it's better to add this node to another empty node. For example, to create a FPS game's hero, I import the dae file to a node named model and added it to the heroNode with a physical body. When the hero runs, assign the model node with the running animation and adjust the heroNode's position. Hopes it will help you.


Anyway, Apple's SpriteKit and SceneKit are the best engines I have ever used. Although Unity and Unreal can create powerful games, they are just so fancy. It's true that Unity paves an easier way for game development: a beginner can successfully create an odinary FPS game in an hour with Unity and YouTube tutorials. However, the most joyful moment only appears when one writes thousands of lines of codes and suddenly the effect s/he wants finally comes alive. Blieve it or not, SpriteKit and SceneKit have opened up a pure world for innovators and deligent developers. So whenever we meet a bug, we should try our best to overcome it as long as we are still alive. Good luck!

SceneKit animation issue
 
 
Q