コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        EaseTarget = CalcPosition();

        transform.position = AnimMath.Dampen(transform.position, EaseTarget, .05f);



        if (IsPlayingForward)
        {
            LittleTime += Time.deltaTime;
            if (LittleTime >= BigTime)
            {
                IsPlayingForward = false;
            }
        }
        else
        {
            LittleTime -= Time.deltaTime;
            if (LittleTime <= 0)
            {
                IsPlayingForward = true;
            }
        }

        //CalcPosition();
    }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (viewTarget == null)
     {
         return;
     }
     transform.position = AnimMath.Dampen(transform.position, viewTarget.position + offset, dampenAmount);
 }
コード例 #3
0
 // Update is called once per frame
 void Update()
 {
     if (isAnimating && cam != null)
     {
         Quaternion targetRot = Quaternion.Euler(0, cam.yaw, 0);
         transform.rotation = AnimMath.Dampen(transform.rotation, targetRot, .01f);
     }
 }
コード例 #4
0
    /// <summary>
    /// Uses lerp to
    /// </summary>
    private void SwivelPosition()
    {
        //if (a == null || b == null) return; //These are float values by definition they will have a value

        float p = curve.Evaluate(percent);

        float targetValue = AnimMath.Lerp(a, b, p);

        xAngle = AnimMath.Dampen(0, targetValue, .5f);
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        var scroll = Input.mouseScrollDelta;

        distance += scroll.y * scrollsensitivity;
        distance  = Mathf.Clamp(distance, 1, 10);
        Vector3 targetPos = new Vector3(0, 0, -distance);

        cam.transform.localPosition = AnimMath.Dampen(cam.transform.localPosition, targetPos, .01f);
    }
コード例 #6
0
    private void CalcPosition()
    {
        if (pos1 == null || pos2 == null)
        {
            return;
        }

        currentEaseTarget = AnimMath.Lerp(pos1.position, planetToFollow.transform.position, percent);

        transform.position = AnimMath.Dampen(transform.position, currentEaseTarget, .5f);
    }
コード例 #7
0
ファイル: LerpMe.cs プロジェクト: jw23r/302-BossGame
    /// <summary>
    /// this function calculates the final postion
    /// of this object between two sperate locations
    /// </summary>
    void Calcposition()
    {
        // transform.position = AnimiMath.Lerp(postionA.position, postionB.position, percent);
        float p = curve.Evaluate(percent);

        //find target postion



        //ease twoard target
        transform.position = AnimMath.Dampen(transform.position, currentEaseTarget, .05f);
        //transform.position +=()
    }
コード例 #8
0
    public void CalcPosition()
    {
        if (currentTransform == null || planetTransform == null)
        {
            return;
        }

        float p = curve.Evaluate(percent);

        currentEaseTarget = AnimMath.Lerp(currentTransform.position, planetTransform.transform.position, p);

        transform.position = AnimMath.Dampen(transform.position, currentEaseTarget - offset, .1f);
    }
コード例 #9
0
ファイル: OrbitCam.cs プロジェクト: jw23r/302-BossGame
    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X"); // how many pixels the mouse has moved left/right
        float mouseY = Input.GetAxis("Mouse Y"); // up and down

        yaw   += mouseX * lookSensitivityX;
        pitch += mouseY * lookSensitivityY;
        pitch  = Mathf.Clamp(pitch, 0, 89);

        Quaternion targetRot = Quaternion.Euler(pitch, yaw, 0);

        transform.rotation = AnimMath.Dampen(transform.rotation, targetRot, 0.001f);
    }
コード例 #10
0
    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxis("Mouse X");
        float mouseY = Input.GetAxis("Mouse Y");

        yaw   += mouseX * lookSensitivityX;
        pitch += mouseY * lookSensitivityY;

        pitch = Mathf.Clamp(pitch, 0, 89);

        Quaternion targetRotation = Quaternion.Euler(pitch, yaw, 0);

        transform.rotation = AnimMath.Dampen(transform.rotation, targetRotation, .001f);
    }
コード例 #11
0
    // Update is called once per frame
    void Update()
    {
        // needs to be cap and space
        float mouseX = Input.GetAxis("Mouse X"); // how many picels the mouse has moved left/right
        float mouseY = Input.GetAxis("Mouse Y"); // how many pixels the mouse has moved up/down

        yaw   += mouseX * lookSensitivityX;
        pitch += mouseY * lookSensitivityY;

        pitch = Mathf.Clamp(pitch, 0, 89);                      // gates how far you can move the camera

        Quaternion targetRot = Quaternion.Euler(pitch, yaw, 0); // 0 is roll


        transform.rotation = AnimMath.Dampen(transform.rotation, targetRot, .001f);
    }
コード例 #12
0
    // Update is called once per frame
    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        if ((v != 0 || h != 0) && theCam != null)
        {
            Quaternion targetRt = Quaternion.Euler(0, theCam.yaw, 0);
            transform.rotation = AnimMath.Dampen(transform.rotation, targetRt, .01f);
        }

        Vector3 moveDis = transform.forward += transform.forward * v * moveSpeed; // * Time.deltaTime;

        moveDis += transform.right * h * moveSpeed;                               // how far to move side-to-side
        body.SimpleMove(moveDis);                                                 // simple move (we think) does deltatime for you
    }
コード例 #13
0
    private void GetInputAndMove()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        isAnimating = (v != 0 || h != 0);

        if (isAnimating && theCam != null)
        {
            Quaternion targetRot = Quaternion.Euler(0, theCam.yaw, 0);
            transform.rotation = AnimMath.Dampen(transform.rotation, targetRot, .01f);
        }


        Vector3 moveDis = transform.forward * v * moveSpeed; // how far to move forward/back

        moveDis += transform.right * h * moveSpeed;          // how far to move side-to-side

        body.SimpleMove(moveDis);                            // does collision, applies gravity, applies deltaTime
    }
コード例 #14
0
ファイル: LookAt.cs プロジェクト: nickworks/SimpleCharacter
    void Update()
    {
        if (targetingScript == null)
        {
            return;
        }

        Vector3 lookAt    = targetingScript.transform.forward;
        bool    hasTarget = (targetingScript.target != null);

        if (hasTarget)
        {
            lookAt = targetingScript.target.position - transform.position;

            // no "vertical-ness" in the look vector
            // in otherwords, flatten the vector onto the x/z plane
            if (isTorso)
            {
                lookAt.y = 0;
            }

            lookAt.Normalize();
        }

        float angleDiff = Vector3.Angle(targetingScript.transform.forward, lookAt);

        Quaternion targetRotation = transform.parent.rotation;

        bool isArmButNotAiming = (isArm && !targetingScript.isAiming);

        if (hasTarget && angleDiff < fieldOfView && !isArmButNotAiming)
        {
            targetRotation = Quaternion.LookRotation(lookAt, Vector3.up);
        }
        else if (isArm)
        {
            targetRotation = Quaternion.LookRotation(transform.parent.up * -1, transform.parent.forward);
        }

        transform.rotation = AnimMath.Dampen(transform.rotation, targetRotation, .001f);
    }
コード例 #15
0
    /// <summary>
    /// this function calculates the final postion
    /// of this object between two sperate locations
    /// </summary>
    void Calcposition()
    {
        if (postionA == null)
        {
            return;
        }
        if (postionB == null)
        {
            return;
        }
        // transform.position = AnimiMath.Lerp(postionA.position, postionB.position, percent);
        float p = curve.Evaluate(percent);

        //find target postion
        if (delayTimer >= delayTarget)
        {
            currentEaseTarget = AnimMath.Lerp(postionA.position, postionB.position, p);
        }
        //ease twoard target
        transform.position = AnimMath.Dampen(transform.position, currentEaseTarget, .05f);
        //transform.position +=()
    }
コード例 #16
0
    /// <summary>
    ///
    /// </summary>
    private void Move()
    {
        // print(body.isGrounded);

        if (body.isGrounded)
        {
            h      = Input.GetAxis("Horizontal");
            v      = Input.GetAxis("Vertical");
            input  = new Vector3(h, 0.0f, v);
            input  = transform.forward * v * moveSpeed;
            input += transform.right * h * moveSpeed;
            // walkDir = input * moveSpeed;
            input *= moveSpeed;
            if (v != 0 || h != 0 && theCam != null)
            {
                Quaternion targetRot = Quaternion.Euler(0, theCam.yaw, 0);
                transform.rotation = AnimMath.Dampen(transform.rotation, targetRot, .05f);
            }
            if (Input.GetButton("Jump"))
            {
                Waste.localPosition -= new Vector3(0, 3, 0);
                //       Waste.localPosition -= new Vector3(0, 3, 0);
            }

            if (Input.GetButtonUp("Jump"))
            {
                //  print("i jumped b");
                input.y              = jumpSpeed;
                Waste.localPosition += new Vector3(0, 3, 0);
            }


            // if (input.sqrMagnitude > 1) input.Normalize();
            // walkDir = input * moveSpeed;
        }
        input.y -= gravity * Time.deltaTime;
        walkDir  = input * moveSpeed;
        body.Move(walkDir * Time.deltaTime);
    }
コード例 #17
0
ファイル: FollowCam.cs プロジェクト: jw23r/302-BossGame
    // Start is called before the first frame update


    // Update is called once per frame
    void Update()
    {
        transform.position = AnimMath.Dampen(transform.position, veiwTarget.position + offset, .01f);
    }