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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -