Esempio n. 1
0
    void FixedUpdate()
    {
        raycastDirection = (endPoint.position - startPoint.position).normalized;

        if (IsDebuggingEnabled)
        {
            Debug.DrawRay(startPoint.position, raycastDirection * raycastLength, Color.blue);
        }

        bool isLightSensorHitPlayer = (Physics2D.Raycast(startPoint.position, raycastDirection, raycastLength, PlayerLayerID).collider != null);

        if (isLightSensorHitPlayer && !isSwitchTriggered)
        {
            if (DelayToSwitch > 0)
            {
                Invoke("startSwitch", DelayToSwitch);
            }
            else
            {
                OnLightSensorTriggered?.Invoke(SensorLight);
            }
        }

        isSwitchTriggered = isLightSensorHitPlayer;
    }
Esempio n. 2
0
 void startSwitch()
 {
     OnLightSensorTriggered?.Invoke(SensorLight);
 }