animation - SceneKit Swift3 compiler-error -


i'm trying run animated "dae" model in scenekit:

let url = bundle.main.url(forresource: "art.scnassets/player(walking)", withextension: "dae")     let scenesource = scnscenesource(url: url!, options: [scnscenesource.loadingoption.animationimportpolicy: scnscenesource.animationimportpolicy.playrepeatedly] )     let animationids: nsarray = scenesource?.identifiersofentries(withclass: caanimation)      eachid in animationids {         let animation: caanimation = (scenesource?.entrywithidentifier(eachid as! string, withclass: caanimation.self))!         animations.add(animation)     }     character?._walkanimations = animations 

but compiler throws on line:

let animationids: nsarray = scenesource?.identifiersofentries(withclass: caanimation)

and writes error:

cannot convert value of type '[string]?' specified type 'nsarray'

please me fix problem.

thanks in advance.

why converting [string]? nsarray , convert each element string again, no need of use swift native array , wrapped optional value if let or guard let.

guard let animationids = scenesource?.identifiersofentries(withclass: caanimation) else {     return } eachid in animationids {     if let animation = scenesource?.entrywithidentifier(eachid, withclass: caanimation.self) {         animations.add(animation)     } } character?._walkanimations = animations 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -