コード例 #1
0
 bool hittingCeiling()
 {
     foreach (RaycastHit2D hit in movementControllerScript.VerticalRaycastHits(velocity.y))
     {
         if (hit.transform != null)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
    public List <GameObject> WhatAmITouacing(float direction)
    {
        List <GameObject>   objects = new List <GameObject>();
        List <RaycastHit2D> hits    = movementControllerScript.HorizontalRaycastHits(direction * .001f);

        hits.AddRange(movementControllerScript.VerticalRaycastHits(-0.001f));
        foreach (RaycastHit2D hit in hits)
        {
            if (hit.transform != null)
            {
                if (!objects.Contains(hit.transform.gameObject))
                {
                    objects.Add(hit.transform.gameObject);
                }
            }
        }
        return(objects);
    }