How to update physicsBody whenever the texture while playing an animation?
func createPlayer() {
player = childNode(withName: "player") as! SKSpriteNode
player.position = CGPoint(x: mapNode.tileSize.width, y: mapNode.tileSize.height*3.5)
var Frames: [SKTexture]
Frames = runAnimationHelper.loadTextures(from: SKTextureAtlas(named: "knight_front_ideal"), withName: "knight_front_ideal")
player.run(SKAction.repeatForever(SKAction.animate(with: Frames, timePerFrame: 0.10, resize: false, restore: true)))
player.physicsBody = SKPhysicsBody(texture: player.texture!, size: player.texture!.size())
player.physicsBody?.isDynamic = true
}
Using the above code player have the initial texture physicsBody and not updating with the animation.
Also if I update the physicBody in "update" function of swift then there's a lag of a second which is not acceptable.