Пример #1
0
    public void Respawn()
    {
        if (!FindObjectOfType <GameManager> ().IsDead())
        {
            player.transform.position = startPos;
            player.transform.rotation = startRot;

            player.GetComponent <Animator> ().Play("LOSE00", -1, 0f);
            FindObjectOfType <AudioManager> ().PlayDelayed("Damage_Voice", 1);
            player.GetComponent <Rigidbody> ().velocity        = new Vector3(0f, 0f, 0f);
            player.GetComponent <Rigidbody> ().angularVelocity = new Vector3(0f, 0f, 0f);
        }
    }
Пример #2
0
    // Check entire scene for collisions
    void CheckCollisions()
    {
        // Every pair of collidables
        for (int i = 0; i < collidables.Count - 1; i++)
        {
            for (int j = i + 1; j < collidables.Count; j++)
            {
                Collidable   member1 = collidables[i].gameObject.GetComponent <Collidable>();
                Collidable   member2 = collidables[j].GetComponent <Collidable>();
                LineRenderer l1      = member1.GetComponent <LineRenderer>();
                LineRenderer l2      = member2.GetComponent <LineRenderer>();
                if (IsOverlapping(l1, l2))
                {
                    if (member1 && member2)
                    {
                        // Call collision method for collided, unless previous collision has not yet been resolved
                        if (!member1.collidingWith.Contains(member2) && !member2.collidingWith.Contains(member1))
                        {
                            Debug.Log("Collision Detected " + member1.gameObject.name + " " + member2.gameObject.name);

                            member1.MyOnCollisionEnter(new MyCollision(member2.gameObject));
                            member2.MyOnCollisionEnter(new MyCollision(member1.gameObject));
                            member1.collidingWith.Add(member2);
                            member2.collidingWith.Add(member1);
                        }
                    }
                }
                else
                {
                    member1.collidingWith.Remove(member2);
                    member2.collidingWith.Remove(member1);
                }
            }
        }
    }