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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -