Created
January 18, 2018 04:03
-
-
Save rdelrosario/55c32cffa468e2a58f704539fd9c809d to your computer and use it in GitHub Desktop.
ARKit PhysicsDelegate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PhysicsDelegate : SCNPhysicsContactDelegate | |
{ | |
IList<SCNNode> animatedNodes=new List<SCNNode>(); | |
public override void DidBeginContact(SCNPhysicsWorld world, SCNPhysicsContact contact) | |
{ | |
var nodeA = contact.NodeA; | |
var nodeB = contact.NodeB; | |
SCNNode target = null; | |
if (nodeA.PhysicsBody.CategoryBitMask == (int)BitMaskCategory.Pokemon) | |
{ | |
target = nodeA; | |
} | |
else if (nodeB.PhysicsBody.CategoryBitMask == (int)BitMaskCategory.Pokemon) | |
{ | |
target = nodeB; | |
} | |
if (target != null && !animatedNodes.Contains(target)) | |
{ | |
var targetScale=target.Scale; | |
animatedNodes.Add(target); | |
target.RunAction(SCNAction.Sequence(new SCNAction[]{ | |
SCNAction.ScaleTo(0, 1.0f), | |
SCNAction.ScaleTo(targetScale.X, 2.0f), | |
}),()=>{ | |
animatedNodes.Remove(target); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment