Example #1
0
        Rigidbody PerformCastForTarget(Ray ray)
        {
            //Raycast for objects and order by distance
            RaycastHit[] hits = Physics.SphereCastAll(ray, sphereCastMaxRadius, sphereCastDistance, targetableMask).OrderBy(h => h.distance).ToArray();;

            //If we hit anything
            if (hits.Length > 0)
            {
                foreach (RaycastHit hit in hits)
                {
                    //Find objects that are targetable
                    iTargetable target = hit.collider.GetComponentInParent <iTargetable>();
                    if (target != null)
                    {
                        //Simulate the sphereCast growing in size with distance
                        //This is to account for foreshortening
                        if (InRange(hit, ray))
                        {
                            //If we determine the target is in range
                            return(target.GetRigidbody());
                        }
                    }
                }
            }
            return(null);
        }
Example #2
0
 void OnTriggerStay2D(Collider2D coll)
 {
     otherGameObject = coll.gameObject;
     target          = otherGameObject.GetComponent <iTargetable>();
     if (target == null)
     {
         return;
     }
     target.ChangeColor();
     objectTargeted = true;
 }
Example #3
0
    public void DeactivateTile()
    {
        if (EntityTypeOnTile == EnumHolder.EntityType.Clear)
        {
            movementPenalty  = 0;
            targetableOnTile = null;
        }

        onClick = null;
        BackgroundTile.color = DeactiveColor;
    }