w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Enemy nodes occasionally gets stuck on a wall

Your checks in didBeginContact: don't take in to account that there's no guarantee regarding which body is which in SKPhysicsContact. It looks like you already took that in to account when getting the nodes for player, enemy, contactLineBody1, and contactLineBody2 though, so we can just use those in your if statements:

Instead of:

if (((firstBody.categoryBitMask & fEnemyCategory) != 0)
&& ((secondBody.categoryBitMask & fContactEnemyCategory1) !=

// ...

if (((firstBody.categoryBitMask & fEnemyCategory) != 0) &&
((secondBody.categoryBitMask & fContactEnemyCategory2) != 0))

Just do:

if (enemy && contactLineBody1)

// ...

if (enemy && contactLineBody2)

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.