private void ExplodeByHit() { if (_distructableByHit && _explosionPrefab != null) { var explosion = Instantiate(_explosionPrefab, transform.position, Quaternion.identity) as GameObject; var rigidbody = explosion.GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.velocity = GetComponent <Rigidbody>().velocity; } ExplosionController explosionController = explosion.GetComponent <ExplosionController>(); if (explosionController != null) { explosionController.SetColor(_color); } } if (_scorePrefab != null) { var score = Instantiate(_scorePrefab, transform.position, Quaternion.identity) as GameObject; var text = score.GetComponent <ScoreTextField>(); if (text != null) { text.SetValue(_hitValue); } } }