Пример #1
0
    void RayCheck()
    {
        RaycastHit _hit;
        Ray        _ray;
        Vector3    _pos = Vector3.zero;

        //プレイヤーがいない、もしくはカメラだけで動く状態なら、中心にRayを飛ばす
        if (_player == null || _cameraMove.LockCheck() == true)
        {
            _ray = new Ray(transform.position + new Vector3(0, 0, 0), transform.forward);
        }
        else
        {
            _pos = new Vector3(_player.transform.position.x, _player.transform.position.y + 1, _player.transform.position.z);
            _ray = new Ray(transform.position + new Vector3(0, 0, 0), _pos - this.transform.position);
        }

//#if UNITY_EDITOR
        if (Physics.SphereCast(_ray, 2, out _hit, 100))
        {
            Debug.DrawLine(_ray.origin, _hit.point, Color.red);
        }
//#endif

        if (_hit.collider != null && _hit.collider.tag == "StageObje")
        {
            _stageObj = _hit.collider.gameObject;
            MatChenge(_stageObj, 0.5f);
        }
        else
        {
            _stageObj = null;
        }
    }