swift - SpriteKit applyImpulse crash -


when try use applyimpulse on node app crashes , receive this: fatal error: unexpectedly found nil while unwrapping optional value (lldb) here code:

    self.character.physicsbody = skphysicsbody(rectangleofsize: character.size)     self.character.physicsbody?.affectedbygravity = true     self.character.physicsbody?.categorybitmask = physicscategory.playercat     self.character.physicsbody?.contacttestbitmask = physicscategory.obstaclescat     self.character.physicsbody?.dynamic = true     self.character.physicsbody?.mass = 5     self.character.physicsbody?.friction = 0.5     self.character.physicsbody?.restitution = 0 

and applyimpulse: character.physicsbody?.applyimpulse(cgvectormake(0,100)) have tried few things , issue size of skphysicsbody nil, why is? same if try manually set size.

it means trying apply action or physics onto non-existant node empty , crashes.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -