Skip to content

Load Animations? #1

@arkwl

Description

@arkwl

Hello!

So ive tried to follow your tutorial here: https://blog.pusher.com/animating-3d-model-ar-arkit-mixamo/ and my code is identical to yours but im getting an error thrown at playAnimation(...) because the animations array is empty even though loadAnimations(...) is called. Any explanation? Im fairly new to Swift.

     loadAnimation(withKey: "dancing", sceneName: "IdleFixed", animationIdentifier: "samba_danceFixed-1")
    }
    
    func loadAnimation(withKey: String, sceneName:String, animationIdentifier:String) {
        let sceneURL = Bundle.main.url(forResource: sceneName, withExtension: "dae")
        let sceneSource = SCNSceneSource(url: sceneURL!, options: nil)
        
        if let animationObject = sceneSource?.entryWithIdentifier(animationIdentifier, withClass: CAAnimation.self) {
            // The animation will only play once
            animationObject.repeatCount = 1
            // To create smooth transitions between animations
            animationObject.fadeInDuration = CGFloat(1)
            animationObject.fadeOutDuration = CGFloat(0.5)
            
            // Store the animation for later use
            animations[withKey] = animationObject
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions