Ejemplo n.º 1
0
    void OnCollisionEnter(Collision col)
    {
        var other = col.gameObject.GetComponent <PlayerController>();

        if (other)
        {
//            Debug.Log("Impact " + playerPostFix);

            if (slippers && slippers.name.Contains("Shark"))
            {
                other.collider.enabled = false;
                var dead = Instantiate(brokenBody, other.transform.position, other.transform.rotation) as Transform;
                foreach (var parts in dead.GetComponentsInChildren <Rigidbody>())
                {
                    parts.AddForce(-col.contacts[0].normal * col.relativeVelocity.magnitude, ForceMode.VelocityChange);
                    parts.renderer.material.color = other.color;
                }

                InAudio.PlayAtPosition(GameManager.Instance.gameObject, deathSound, other.gameObject.transform.position);
                Destroy(other.gameObject);
                GameManager.Instance.Respawn(other);

                Services.Get <CameraShake>().ApplyShake(0.4f, 0.5f);
            }

            var impact = Vector3.Project(col.relativeVelocity, col.contacts[0].normal);
            impact *= other.Push / Push;
            rigidbody.AddForce(impact, ForceMode.VelocityChange);
            Services.Get <CameraShake>().ApplyShake(0.2f, 0.2f);
            //Debug.DrawRay(transform.position, impact, Color.red);
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        var player = other.GetComponent <PlayerController>();

        if (player != null)
        {
            InAudio.PlayAtPosition(gameObject, deathSound, other.transform.position);
            Object.Destroy(other.gameObject);
            GameManager.Instance.Respawn(player);
        }
    }