swift - contact even if not directly on physicsbody -


i've got strange behavior of skphysicsbody.

first let me show main-node:

self.physicsworld.contactdelegate = self self.physicsworld.gravity = cgvectormake(0, 0) self.physicsbody = skphysicsbody(rectangleofsize: self.frame.size) self.physicsbody!.collisionbitmask = player self.physicsbody!.categorybitmask = wall self.physicsbody!.contacttestbitmask = player self.physicsbody?.dynamic = true self.name = "background" 

now on top of that, there skspritenode without physicsbody, let's call path.

after time, spawn node, playernode on top of path:

playernode = skspritenode(color: uicolor.blackcolor(), size: cgsizemake(tilesize/1, tilesize/1)) playernode.position = cgpointmake(self.frame.width/2, self.frame.height/2) playernode.zposition = 3  playernode.name = "player"  playernode.physicsbody = skphysicsbody(rectangleofsize: playernode.size) playernode.physicsbody!.categorybitmask = player playernode.physicsbody!.collisionbitmask = wall playernode.physicsbody!.contacttestbitmask = wall playernode.physicsbody?.dynamic = false 

so in opinion, didbegincontact should trigger if playernode moved outside of path node , if touches background.

but @ moment, didbegincontact triggers after spawn playernode on top of path.

am missing something?

having little trouble understanding.. sounds want detect when playernode exits position of path node.

it's triggering physics contact because player node going intersecting scene's physics body no matter what.

in reality dont need physics of this. in update method can check see if player intersecting path node (or whichever nodes care about). if it's not intersecting those, it's sitting directly in world, scene, etc.

inside of update:

if !playernode.intersectsnode(path) {     // code here 

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 -