Exemplo n.º 1
0
        void OnUpdade()
        {
            #if UNITY_EDITOR
            if (Application.isPlaying)
            {
            #endif
            if (connectedBody)
            {
                wheelPivot.position = VectorOperator.getWordPosition(absorber, localPosition);
                if (turnBody)
                {
                    if (lineralDamper)
                    {
                        wheelPivot.transform.LookAt(wheelPivot.transform.position + steering.transform.up, -steering.transform.forward);
                    }
                    else
                    {
                        wheelPivot.LookAt(wheelPivot.position + Vector3.ProjectOnPlane(turnBody.transform.forward, root.up).normalized, root.up);
                    }
                }

                float angularVelocityX = Vector3.Dot(body.angularVelocity, wheelPivot.right);

                if (Mathf.Abs(angularVelocityX) > 0.9f)
                {
                    transform.RotateAround(wheelPivot.position, wheelPivot.right, (180.0f / Mathf.PI) * angularVelocityX * Time.deltaTime);
                }
            }
                #if UNITY_EDITOR
        }
                #endif
        }
Exemplo n.º 2
0
    public static void MoveBallInQuad(Transform cube, float radius, Vector3 hitPoint, ref Vector3 position)
    {
        if (sphereInCube(hitPoint, radius, cube))
        {
            position = hitPoint;
        }
        else
        {
            Vector3 _ballMoveLocalPosition = VectorOperator.getLocalPosition(cube, hitPoint);

            if (!(Mathf.Abs(_ballMoveLocalPosition.x) <= -radius + 0.5f * cube.localScale.x))
            {
                if (Mathf.Abs(_ballMoveLocalPosition.z) <= -radius + 0.5f * cube.localScale.z)
                {
                    Vector3 ballMovePositionX = _ballMoveLocalPosition.x > 0.0f? VectorOperator.getWordPosition(cube, (-radius + 0.5f * cube.localScale.x) * Vector3.right): VectorOperator.getWordPosition(cube, (radius - 0.5f * cube.localScale.x) * Vector3.right);
                    position = new Vector3(ballMovePositionX.x, position.y, hitPoint.z);
                }
            }
            else
            {
                if (Mathf.Abs(_ballMoveLocalPosition.x) <= -radius + 0.5f * cube.localScale.x)
                {
                    Vector3 ballMovePositionZ = _ballMoveLocalPosition.z > 0.0f? VectorOperator.getWordPosition(cube, (-radius + 0.5f * cube.localScale.z) * Vector3.forward):
                                                VectorOperator.getWordPosition(cube, (radius - 0.5f * cube.localScale.z) * Vector3.forward);
                    position = new Vector3(hitPoint.x, position.y, ballMovePositionZ.z);
                }
            }
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        if (controller.NewPoseName == "Rotate left" || controller.NewPoseName == "Rotate right" || controller.NewPoseName == "From Rotate left" || controller.NewPoseName == "From Rotate right" ||
            controller.NewPoseName == "Left turn" || controller.NewPoseName == "Right turn")
        {
            position = VectorOperator.getWordPosition(aviator, localPosition);
        }
        else
        {
            position = deltaPosition + aviator.position;
        }
        //position = VectorOperator.getWordPosition(aviator, localPosition);
        if (controller.inAnimate)
        {
            _transform.position = Vector3.Lerp(_transform.position, position, 1.0f * damp * Time.deltaTime);
        }
        else
        {
            _transform.position = Vector3.Lerp(_transform.position, position, damp * Time.deltaTime);
        }


        aviatorPosition = Vector3.Lerp(aviatorPosition, aviator.position, 2.0f * damp * Time.deltaTime);
        _transform.LookAt(aviatorPosition);
    }
Exemplo n.º 4
0
        void LateUpdate()
        {
            if (!downDetailParent)
            {
                enabled = false;
                return;
            }
            springDownDetail.position = VectorOperator.getWordPosition(downDetailParent, localPosition);
            springDownDetail.LookAt(springUpDetail.position);
            springUpDetail.LookAt(springDownDetail.position);

            float deltaDistance = Vector3.Distance(downPivot.position, upPivot.position) / detailsStartDistance;

            spring.localScale = new Vector3(springStartScale.x, springStartScale.y, springStartScale.z * deltaDistance);
        }