-1

I have two nodes one near another. And I want one node to be on top of another when I tap. I do so like this:

SKAction *moveUp=   [SKAction moveByX:0 y:25 duration:0.1];
SKAction *moveDown= [SKAction moveByX:0 y:-25 duration:0.1];
SKAction *playerSequence = [SKAction sequence:@[moveUp,moveDown]];
[self.player runAction:[SKAction repeatAction:playerSequence count:1] withKey:@"attack"];

And instead I get that one node pushes the other (bots nodes created via editor and both body type is set to none).

I tried adding these to didMoveToView on both nodes:

node.physicsBody.dynamic = NO;
node.physicsBody.collisionBitMask = 0;
node.physicsBody.contactTestBitMask = 0;
node.physicsBody.affectedByGravity = NO;

I even tried setting velocity to 0 on Update. And still no effect.

Stefan
  • 5,203
  • 8
  • 27
  • 51
HelloimDarius
  • 695
  • 5
  • 23

2 Answers2

1

Set your bit masks in -(void)didBeginContact:(SKPhysicsContact *)contact as shown in this post.

I think you have a timing issue if you set the bit masks in didMoveToView because only one of those will be run at a time and both physics bodies will need to mutually agree not contact each other.

Community
  • 1
  • 1
jaybers
  • 1,991
  • 13
  • 18
1

You have to set the physics body to nil:

node.physicsBody = nil;
Stefan
  • 5,203
  • 8
  • 27
  • 51