示例#1
0
    public void OnObjectSpawn()
    {
        objPooler  = ObjectPooler.Instance;
        rayManager = RaycastManager.Instance;
        camMove    = CameraMovement.Instance;
        rb         = GetComponent <Rigidbody>();
        isEnemy    = rayManager.CheckIsEnemy();

        if (!isEnemy)
        {
            target = rayManager.lastHitPosition;
        }
    }
    // Update is called once per frame
    void LateUpdate()
    {
        if (Input.GetMouseButton(0) || crosshair.anchoredPosition != rayManager.CalculateScreenPosition(rayManager.lastHitPosition))
        {
            switch (rayManager.CheckIsEnemy())
            {
            case true:
                crosshair.anchoredPosition = rayManager.CalculateScreenPosition(rayManager.lastHitTransform.position);
                break;

            case false:
                crosshair.anchoredPosition = rayManager.CalculateScreenPosition(rayManager.lastHitPosition);
                break;
            }
        }
    }