public void OnMatterTouch(Matter otherMatter, Matter hitter) { if (CurrentState != PlayerState.Existing) { return; } if (otherMatter == null) { Debug.LogError("how the hell did we hit a null matter"); } otherMatter.CaptureObject(this); //Vector3 currentMomentum = MasterRigidbody.mass * MasterRigidbody.velocity; //Vector3 totalMomentum = otherMatter.Rigidbody.mass * otherMatter.Rigidbody.velocity + currentMomentum; //if(totalMomentum.magnitude < MomentumCap) //{ // MasterRigidbody.velocity = totalMomentum / MasterRigidbody.mass; //} MasterRigidbody.mass += otherMatter.Rigidbody.mass; if (MasterRigidbody.mass < 1) { MasterRigidbody.mass = 1; } if (MasterRigidbody.mass >= PlanetMassRequirement) { try { MusicManager.Instance.PlayIntenseMusic(); } catch { Debug.LogError("Music manager not found!"); } } CapturedObjects.Add(otherMatter); var well = otherMatter.gameObject.AddComponent <GravityWell>(); well.Range = ChildGravitySize; well.GravityStrength = ChildGravityStrengthMultiplier * otherMatter.Mass; UpdateSpeed(); var node = Root.FindChild(hitter); if (node == null && Root.Node == hitter) { node = Root; } if (node == null) { Debug.LogError("Somehow a null matter reported a hit??"); return; } node.AttachChild(otherMatter); }