ios - Double notification on contact in spriteKit -


When my SKSpriteNode contacts with the WorldCatter, I get a double notification, how is it? This problem arises when I want to take action on touching the world class, because the action is being triggered

Here is my bitmask in the intuitive system method

  Mover.physicsBody .categoryBitMask = birdCategory; Below. Physics Body Character bit mask = world category; Mower.FixixBodyContactTestBitMask = WorldCategory;  

And the contact method here is:

  - (zero) done Thabin contact: (SKPSisCactact *) Contact {if (contact.bodyA.categoryBitMask == worldcategory) {Mower.Textic = [Skeleton Texture with Image: @ "Birddid 1"]; NSLog (@ "Contact"); Self.scene.paused = yes; [Pausabutan removal prospewview]; }}  

Two lines are shown with "Contacts" in my logs

Set the restitution property to zero in your object such as:

  self.physicsBody.restitution = 0; // This is the name of yourself or your object  

If it does not solve your problem, then see the movement code related to your object (s) View any condition that is' behind And behind 'causes movement that can cause double contact problems.

As a last resort, you can set a filter for your contacts:

  1. Create a variable that stores when creating a contact.
  2. Compare the contact variable time against the current time in the update: method.
  3. If the difference is allowed at your specified time (eg 0.2 seconds) then contact and set your contact time variable at the current time. If the difference is below the filter time (0.2 seconds), then ignore the contact.

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -