Пример #1
0
    void OnCollisionEnter(Collision col)
    {
        List <string> collision_collider_names = new List <string>();

        for (int i = 0; i < col.contacts.Length; i++)
        {
            if (
                (col.contacts [i].thisCollider.enabled) &&
                (col.contacts[i].thisCollider.name == gameObject.name) &&
                !collision_collider_names.Contains(col.collider.name)
                )
            {
                Debug.Log("Grav RB Colliding with " + col.collider.name);
                if (col.collider.name == "left_hand")
                {
                    this.GetComponent <PlayerMovementManager>().request_death();
                    Animator other_animator = col.collider.transform.parent.parent.GetComponent <Animator> ();
                    Physics.IgnoreCollision(grav_collider, col.collider.transform.parent.parent.parent.GetComponent <BoxCollider> ());
                    if (!animator.GetCurrentAnimatorStateInfo(PlayerAnimatorStates.default_anim_layer_index).IsName(PlayerAnimatorStates.death_state_id))
                    {
                        if (other_animator.GetBool(PlayerAnimatorParameters.is_facing_left))
                        {
                            Instantiate(explosion_particles, col.contacts[i].point, Quaternion.Euler(new Vector3(0, 0, 90)));
                        }
                        ;
                        if (other_animator.GetBool(PlayerAnimatorParameters.is_facing_right))
                        {
                            Instantiate(explosion_particles, col.contacts[i].point, Quaternion.Euler(new Vector3(0, 0, -90)));
                        }
                        ;
                    }
                }
                if (col.collider.name == "OutOfBounds")
                {
                    p_sound_m.play_out_of_bounds_fx();
                    p_score_m.decrement_score();
                    pmm.request_reset_position();
                }
                collision_collider_names.Add(col.collider.name);
            }
        }

        pmm.request_landing();
    }