Exemple #1
0
    public List <GameObject> WhatAmIFacing(float direction)
    {
        List <GameObject> objects = new List <GameObject>();

        if (direction != 0)
        {
            direction = Mathf.Sign(direction);

            List <RaycastHit2D> hits = movementControllerScript.HorizontalRaycastHits(direction * .01f);

            for (int i = 0; i < hits.Count / 2; i++)
            {
                RaycastHit2D hit = hits[i];

                if (hit.transform != null)
                {
                    if (!objects.Contains(hit.transform.gameObject))
                    {
                        objects.Add(hit.transform.gameObject);
                    }
                }
            }
        }
        return(objects);
    }
Exemple #2
0
    public List <GameObject> WhatAmIFacing(float direction)
    {
        List <GameObject>   objects = new List <GameObject>();
        List <RaycastHit2D> hits    = movementControllerScript.HorizontalRaycastHits(direction * .001f);

        foreach (RaycastHit2D hit in hits)
        {
            if (hit.transform != null)
            {
                if (!objects.Contains(hit.transform.gameObject))
                {
                    objects.Add(hit.transform.gameObject);
                }
            }
        }
        return(objects);
    }