Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Last active January 20, 2020 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anupamchugh/0829964865b25bae3880dcd14c6741b0 to your computer and use it in GitHub Desktop.
Save anupamchugh/0829964865b25bae3880dcd14c6741b0 to your computer and use it in GitHub Desktop.
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