Пример #1
0
    protected override void Enter()
    {
        _animator.SetTrigger("Die");
        _onDied.Invoke();
        gameObject.layer = 8;
        _distance.CheckBest(_highScore);
        StartCoroutine(StopAfterFalling(transform.position.y));
        _distance.enabled = false;
        _cameraFocus.Detach();
        Vector2 randomForce     = Random.insideUnitCircle;
        Vector2 forceFromCurves = new Vector2(_xForce.Evaluate(randomForce.x), _yForce.Evaluate(randomForce.y));

        _rigidBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezePositionZ;
        _collider.material     = _deadMaterial;
        _rigidBody.velocity    = Vector3.zero;
        _rigidBody.AddForce(forceFromCurves * _forceScale, ForceMode.Impulse);
        _rigidBody.AddTorque(Random.insideUnitSphere * _torqueScale, ForceMode.Impulse);
        _deathParticles.Play();
    }