示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (!isBalancing)
        {
            return;
        }

        // Move towards the other rope node.
        transform.LookAt(_moveTowards);

        // Walk slowly forward, it should be facing the node at the other end.
        CrossPlatformInputManager.SetAxis("Horizontal", 0);
        CrossPlatformInputManager.SetAxis("Vertical", characterSpeed);


        var difference = BalanceAngleDifference();

        dialRoot.rotation = Quaternion.Euler(0, 0, difference);

        Camera.main.transform.Rotate(Vector3.forward, difference * characterSpeed, Space.Self);

        if (difference > angleThreshold || difference < _inverseAngleThreshold)
        {
            // What happens when it's too much? We fall off I assume.
            print("Fall off");
            // Why can't I add force here? Is there some tick box on?
            var rb = _character.GetComponent <Rigidbody>();
            rb.AddForce(new Vector3(1, 1, 0) * difference);
            // Whatever happens, we still have to end the balance.
            EndBalance();
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     dos.enabled  = false;
     tres.enabled = false;
     joystick     = GameObject.FindWithTag("Joystick").GetComponent <FixedJoystick>();
     jump.GetComponent <Button>().onClick.AddListener(() => control.m_Jump = true);
     control.GetComponent <ThirdPersonUserControl>();
     camaras.onClick.AddListener(() => ButtonClicked());
 }
示例#3
0
    public void UpdateATL(ThirdPersonUserControl player, CurvySpline spline)
    {
        if (!init && spline.IsInitialized)
        {
            init = true;
        }

        if (!init)
        {
            return;
        }

        if (!Camera.main.GetComponent <CameraController_three> ().CUbool&& !wasdDone)
        {
            //player.GetComponentInChildren<MakeMesh> (true).enabled = true;
            MakeTextGO("TO MOVE HOLD DOWN WASD");              //0-17 before "W"
            wasdDone = true;
        }
        if (Input.GetKeyDown(KeyCode.W) && !wPressed)
        {
            SwapCharGO(' ', 14);             // replace W with a space
            wPressed = true;
        }
        if (Input.GetKeyDown(KeyCode.A) && !aPressed)
        {
            SwapCharGO(' ', 15);
            aPressed = true;
        }
        if (Input.GetKeyDown(KeyCode.S) && !sPressed)
        {
            SwapCharGO(' ', 16);
            sPressed = true;
        }
        if (Input.GetKeyDown(KeyCode.D) && !dPressed)
        {
            SwapCharGO(' ', 17);
            dPressed = true;
        }

        // conditionals for which words to show
        if (wPressed && sPressed && aPressed && dPressed && !wasdCleared)
        {
            Clear();
            wasdCleared = true;
        }
        if (player.GetComponent <ThirdPersonCharacter> ().SeenGun() && !qDone && wasdCleared)         //must evade intro wide with gun in view
        {
            MakeTextGO("PRESS Q TO PICKUP");
            qDone = true;
        }
        if (player.GetComponent <ThirdPersonCharacter> ().m_pickup == true && !mouseAimDone)
        {
            MakeTextGO("PRESS LEFT MOUSE DOWN TO AIM");
            mouseAimDone = true;
        }
        if (player.GetComponent <ThirdPersonCharacter> ().m_doneAim == true && !mouseFireDone)
        {
            MakeTextGO("RELEASE LEFT MOUSE TO FIRE");
            mouseFireDone = true;
            //StartCoroutine (Fade (4.0f)); //do on fireFlag below
        }
        if (player.GetComponent <ThirdPersonCharacter> ().m_fireFlag == true & !fireCleared)
        {
            Clear();
            fireCleared = true;
        }

        float t = spline.GetNearestPointTF(player.transform.position);

        //AxKDebugLines.AddSphere (spline.Interpolate (maxT), 0.3f, Color.green);
        //AxKDebugLines.AddSphere (spline.Interpolate (minT), 0.3f, Color.magenta);

        Vector3 splineUp      = spline.GetRotatedUpFast(t, 0);
        Vector3 splineForward = spline.GetTangent(t);
        Vector3 splineRight   = Vector3.Cross(splineUp, splineForward);

        //Vector3 rise = splineRight * offset.x + splineUp * offset.y + splineForward * offset.z;

        Vector3 lookPosition = Camera.main.transform.position;
        //Vector3 targetPosition = player.transform.position + player.transform.right * 0.8f * textLength / 4 + player.transform.up * 4.0f - player.transform.forward * 3.0f;
        Vector3 targetPosition = spline.Interpolate(t) + splineRight * 0.8f * textLength / 3 + splineUp * 4.0f - splineForward * 3.0f;

        //AxKDebugLines.AddSphere (lookPosition, .1f, Color.red);
        //AxKDebugLines.AddSphere (targetPosition, .1f, Color.blue);

        transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smooth);
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation((lookPosition - transform.position).normalized), Time.deltaTime * smooth);
    }