Last active
January 20, 2020 11:34
-
-
Save anupamchugh/0829964865b25bae3880dcd14c6741b0 to your computer and use it in GitHub Desktop.
This file contains 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
extension CustomEntity { | |
func addCollisions() { | |
guard let scene = self.scene else { | |
return | |
} | |
collisionSubs.append(scene.subscribe(to: CollisionEvents.Began.self, on: self) { event in | |
guard let boxA = event.entityA as? CustomEntity else { | |
return | |
} | |
boxA.model?.materials = [SimpleMaterial(color: .red, isMetallic: false)] | |
}) | |
collisionSubs.append(scene.subscribe(to: CollisionEvents.Ended.self, on: self) { event in | |
guard let boxA = event.entityA as? CustomEntity else { | |
return | |
} | |
boxA.model?.materials = [SimpleMaterial(color: .yellow, isMetallic: false)] | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment