private void OnTriggerEnter2D(Collider2D collision)
    {  //check collision with walls and trails.
        if (collision.gameObject.tag == "Trail" && Alive == true || collision.gameObject.tag == "Walls" && Alive == true)
        {
            TrailHandler handler = TrailManager.Instance.activeTrails[index].Handler;
            handler.Renderer.emitting = false;
            if (collision.gameObject.tag == "Trail")
            {
                TrailData tempdata = collision.gameObject.GetComponent <TrailCollision>().TrailData;
                if (tempdata.beforeSplitTrail == null)
                {
                    tempdata.TrailCollider.SplitPoint(transform, tempdata.Handler.transform);
                }
                else
                {
                    tempdata.TrailCollider.SubSplit(tempdata.beforeSplitTrail, transform);
                }

                collision.gameObject.SetActive(false);
            }
            else
            {
                handler.NewAtColl();
            }
            Death();
        }
    }
예제 #2
0
    public void SplitPoint(Transform collidingPlayer, Transform trailOwner)
    {   //we gonna find the closest collision point, find the closest position on the trailCollider, then split at that index.
        int          breakIndex    = FindBreakPoint(collidingPlayer.position, collider2D);
        TrailHandler originalTrail = trailOwner.GetComponent <TrailHandler>();

        SplitCollider(originalTrail, breakIndex);

        if (transform.parent.name != "StaticTrails")
        {
            originalTrail.NewAtColl();
        }
        collidingPlayer.GetComponent <TrailHandler>().NewAtColl();
    }