Beispiel #1
0
    private void shootRays()
    {
        transform.Rotate(0, 0, Time.deltaTime * laserRotationSpeed);

        GetRaycastPoints();
        Vector3[] rayCastPointsDirections = { (transform.up - transform.right).normalized, (transform.up + transform.right).normalized, (-transform.up - transform.right).normalized, (-transform.up + transform.right).normalized };
        for (int i = 0; i < 4; i++)
        {
            lineRenderers[i].origin = transform.position;
            Debug.DrawRay(transform.position, rayCastPointsDirections[i].normalized * rayLength, Color.red);
            RaycastHit hit;
            if (Physics.Raycast(transform.position, rayCastPointsDirections[i].normalized, out hit, rayLength))
            {
                if (hit.collider.gameObject.CompareTag("Player"))
                {
                    controller = hit.collider.GetComponent <FirstPersonController>();
                    controller.Death();
                }
            }
            if (hit.point != Vector3.zero)
            {
                lineRenderers[i].destination = hit.point;
            }
            else
            {
                lineRenderers[i].destination = transform.position + rayCastPointsDirections[i].normalized * rayLength;
            }
        }
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        FirstPersonController myScript = (FirstPersonController)target;

        if (GUILayout.Button("Death"))
        {
            myScript.Death();
        }
    }