public void DidCollision(SCNNode node, SCNNode otherNode, SCNVector3 pos, float impulse) { var gameObject = node.NearestParentGameObject(); if (gameObject != null && gameObject is Catapult catapult) { var otherGameObject = otherNode.NearestParentGameObject(); if (otherGameObject != null) { // Projectile case if (otherGameObject is Projectile projectile) { var catapultNode = catapult.Base; if (catapultNode.PhysicsBody == null) { throw new Exception("Catapult has no physicsBody"); } // Do not let projectile from the same team kill the catapult if (catapult.Team == projectile.Team) { catapultNode.PhysicsBody.Velocity = SCNVector3.Zero; catapultNode.PhysicsBody.AngularVelocity = SCNVector4.UnitY; } } // Server tries to release the catapult if it got impulse from block or projectile if (impulse > MinImpuseToReleaseCatapult) { if (this.Delegate == null) { throw new Exception("No delegate"); } if (this.Delegate.IsServer) { // Any game objects (blocks or projectiles) case var data = new GrabInfo(catapult.CatapultId, catapult.LastCameraInfo); this.Delegate.DispatchActionToServer(new GameActionType { TryRelease = data, Type = GameActionType.GActionType.TryRelease }); } } } } }