Beispiel #1
0
    private void MoveStep()
    {
        if (!(path != null && path.Length > 0 && stepIndex < path.Length))
        {
            return;
        }
        nodePostion = GridMap.GetCenterPoint(path[stepIndex].x, path[stepIndex].y);
        nodePostion = GetOnGroundPoint(nodePostion);
        if (FPVector.Distance(FPTransform.position, nodePostion) < Speed * FrameSyncManager.DeltaTime)
        {
            FPTransform.position = nodePostion;
            if (stepIndex < path.Length)
            {
                if (stepIndex == path.Length - 1)
                {
                    velocity = FPVector.zero;
                }
                stepIndex++;
            }
        }
        else
        {
            velocity = (nodePostion - FPTransform.position).normalized * Speed * FrameSyncManager.DeltaTime;
            FPTransform.LookAt(new FPVector(nodePostion.x, FPTransform.position.y, nodePostion.z));
            FPTransform.Translate(velocity, Space.World);
        }
//         Debug.LogWarningFormat("{0} FPTransform.position:{1},endNode:{2},stepIndex:{3},Length:{4},node:{5},position:{6}",
//             name, GridMap.getIndex(FPTransform.position), endNode, stepIndex, path.Length, path[stepIndex],FPTransform.position);
    }
Beispiel #2
0
    public Fix64 TestCollision(FPVector myRootPosition, FPVector opRootPosition, HitBox[] opHitBoxes)
    {
        Fix64 totalPushForce = 0;

        foreach (HitBox hitBox in hitBoxes)
        {
            if (hitBox.collisionType != CollisionType.bodyCollider)
            {
                continue;
            }
            foreach (HitBox opHitBox in opHitBoxes)
            {
                if (opHitBox.collisionType != CollisionType.bodyCollider)
                {
                    continue;
                }
                FPVector opHitBoxPosition = opHitBox.mappedPosition + opRootPosition;
                FPVector hitBoxPosition   = hitBox.mappedPosition + myRootPosition;

                if (!UFE.config.detect3D_Hits)
                {
                    opHitBoxPosition.z = 0;
                    hitBoxPosition.z   = 0;
                }
                Fix64 dist = FPVector.Distance(opHitBoxPosition, hitBoxPosition);
                if (dist <= opHitBox._radius + hitBox._radius)
                {
                    totalPushForce += (opHitBox._radius + hitBox._radius) - dist;
                }
            }
        }
        return(totalPushForce);
    }
Beispiel #3
0
 public void goToDestination(FPVector destPositon)
 {
     if (FPVector.Distance(FPTransform.position, destPositon) < Speed * FrameSyncManager.DeltaTime)
     {
         FPTransform.position = destPositon;
     }
     else
     {
         var v = (destPositon - FPTransform.position).normalized * Speed * FrameSyncManager.DeltaTime;
         FPTransform.LookAt(new FPVector(destPositon.x, FPTransform.position.y, destPositon.z));
         FPTransform.Translate(v, Space.World);
     }
 }
Beispiel #4
0
    public static FPVector[] TestCollision(FPVector rootPosition, HitBox[] hitBoxes, HurtBox[] hurtBoxes, HitConfirmType hitConfirmType, int mirror)
    {
        foreach (HitBox hitBox in hitBoxes)
        {
            if (hitBox.hide)
            {
                continue;
            }
            if (hitBox.collisionType == CollisionType.noCollider)
            {
                continue;
            }
            if (hitConfirmType == HitConfirmType.Throw && hitBox.collisionType != CollisionType.throwCollider)
            {
                continue;
            }
            if (hitConfirmType == HitConfirmType.Hit && hitBox.collisionType == CollisionType.throwCollider)
            {
                continue;
            }

            hitBox.state = 0;
            //drawRect.Clear();
            foreach (HurtBox hurtBox in hurtBoxes)
            {
                FPVector hurtBoxPosition = hurtBox.position;
                FPVector hitBoxPosition  = hitBox.mappedPosition + rootPosition;

                Fix64 dist             = 0;
                bool  collisionConfirm = false;

                if (!UFE.config.detect3D_Hits)
                {
                    hurtBoxPosition.z = 0;
                    hitBoxPosition.z  = 0;
                }

                if (hurtBox.shape == HitBoxShape.circle)
                {
                    if (hitBox.shape == HitBoxShape.circle)
                    {
                        dist = FPVector.Distance(hurtBoxPosition, hitBoxPosition);
                        if (dist <= hurtBox._radius + hitBox._radius)
                        {
                            collisionConfirm = true;
                        }
                    }
                    else if (hitBox.shape == HitBoxShape.rectangle)
                    {
                        FPRect hitBoxRectanglePosition = hitBox._rect;
                        hitBoxRectanglePosition.x += hitBoxPosition.x;
                        hitBoxRectanglePosition.y += hitBoxPosition.y;
                        hitBoxRectanglePosition.RefreshPoints();

                        if (hitBox.followXBounds)
                        {
                            //hitBoxRectanglePosition.x = hitBox.rendererBounds.x - (hitBox.rect.width / 2);
                            //hitBoxRectanglePosition.width = (hitBox.rendererBounds.width + hitBox.rect.width) - hitBox.rendererBounds.x;
                        }
                        if (hitBox.followYBounds)
                        {
                            //hitBoxRectanglePosition.y = hitBox.rendererBounds.y - (hitBox.rect.height / 2);
                            //hitBoxRectanglePosition.height = (hitBox.rendererBounds.height + hitBox.rect.height) - hitBox.rendererBounds.y;
                        }

                        dist = hitBoxRectanglePosition.DistanceToPoint(hurtBoxPosition);
                        if (hurtBox._radius >= dist)
                        {
                            collisionConfirm = true;
                        }

                        /*if (collisionConfirm && !hurtBox.isBlock) {
                         *  Debug.Log("------------------");
                         *  Debug.Log(hurtBoxPosition);
                         *  Debug.Log(hitBox.bodyPart + " - " + hitBoxRectanglePosition);
                         *  Debug.Log("xMin/xMax,yMin/yMax : " + hitBoxRectanglePosition.xMin + "/" + hitBoxRectanglePosition.xMax + ", " + hitBoxRectanglePosition.yMin + "/" + hitBoxRectanglePosition.yMax);
                         *  Debug.Log(hurtBox.radius + " >= " + dist + " = " + collisionConfirm);
                         * }*/
                    }
                }
                else if (hurtBox.shape == HitBoxShape.rectangle)
                {
                    FPRect hurtBoxRectanglePosition = hurtBox._rect;
                    if (mirror < 0)
                    {
                        hurtBoxRectanglePosition.x += hurtBoxRectanglePosition.width;
                    }
                    hurtBoxRectanglePosition.x *= mirror;
                    hurtBoxRectanglePosition.x += hurtBoxPosition.x;
                    hurtBoxRectanglePosition.y += hurtBoxPosition.y;
                    hurtBoxRectanglePosition.RefreshPoints();

                    if (hitBox.shape == HitBoxShape.circle)
                    {
                        if (hurtBox.followXBounds)
                        {
                            //hurtBoxRectanglePosition.x = hurtBox.rendererBounds.x - (hurtBox.rect.width/2);
                            //hurtBoxRectanglePosition.width = (hurtBox.rendererBounds.width + hurtBox.rect.width) - hurtBox.rendererBounds.x;
                        }
                        if (hurtBox.followYBounds)
                        {
                            //hurtBoxRectanglePosition.y = hurtBox.rendererBounds.y - (hurtBox.rect.height/2);
                            //hurtBoxRectanglePosition.height = (hurtBox.rendererBounds.height + hurtBox.rect.height) - hurtBox.rendererBounds.y;
                        }

                        dist = hurtBoxRectanglePosition.DistanceToPoint(hitBoxPosition);
                        if (dist <= hitBox._radius)
                        {
                            collisionConfirm = true;
                        }
                    }
                    else if (hitBox.shape == HitBoxShape.rectangle)
                    {
                        FPRect hitBoxRectanglePosition = hitBox._rect;
                        //if (mirror > 0) hitBoxRectanglePosition.x += hitBoxRectanglePosition.width;
                        //hitBoxRectanglePosition.x *= -mirror;
                        hitBoxRectanglePosition.x += hitBoxPosition.x;
                        hitBoxRectanglePosition.y += hitBoxPosition.y;
                        hitBoxRectanglePosition.RefreshPoints();


                        if (hitBox.followXBounds)
                        {
                            //hitBoxRectanglePosition.x = hitBox.rendererBounds.x - (hitBox.rect.width/2);
                            //hitBoxRectanglePosition.width = (hitBox.rendererBounds.width + hitBox.rect.width) - hitBox.rendererBounds.x;
                        }
                        if (hitBox.followYBounds)
                        {
                            //hitBoxRectanglePosition.y = hitBox.rendererBounds.y - (hitBox.rect.height/2);
                            //hitBoxRectanglePosition.height = (hitBox.rendererBounds.height + hitBox.rect.height) - hitBox.rendererBounds.y;
                        }

                        if (hurtBox.followXBounds)
                        {
                            //hurtBoxRectanglePosition.x = hurtBox.rendererBounds.x - (hurtBox.rect.width/2);
                            //hurtBoxRectanglePosition.width = (hurtBox.rendererBounds.width + hurtBox.rect.width) - hurtBox.rendererBounds.x;
                        }
                        if (hurtBox.followYBounds)
                        {
                            //hurtBoxRectanglePosition.y = hurtBox.rendererBounds.y - (hurtBox.rect.height/2);
                            //hurtBoxRectanglePosition.height = (hurtBox.rendererBounds.height + hurtBox.rect.height) - hurtBox.rendererBounds.y;
                        }

                        if (hurtBoxRectanglePosition.Intersects(hitBoxRectanglePosition))
                        {
                            collisionConfirm = true;
                        }
                    }
                }

                if (collisionConfirm)
                {
                    if (hitConfirmType == HitConfirmType.Hit)
                    {
                        hitBox.state = 1;
                    }
                    return(new FPVector[] { hurtBoxPosition, hitBoxPosition, (hurtBoxPosition + hitBoxPosition) / 2 });
                }
            }
        }

        foreach (HitBox hitBox in hitBoxes)
        {
            if (hitBox.state == 1)
            {
                hitBox.state = 0;
            }
        }
        return(new FPVector[0]);
    }
Beispiel #5
0
    public void Update()
    {
        if (Target == null)
        {
            return;
        }
        //  ChangeDirectionByDragging();
        //if (_dragging && _directorToLeft && !_bTouchMouse)  //左遥感
        //{
        //    _rockerControl = ComMoveController.RockerControl.LeftControl;
        //    _ufpTransform.RotateAround(_playerTransformObj.position, FPVector.up, FrameSyncManager.DeltaTime * RockerSpeed);
        //    _ufpTransform.UpdateAllData();
        //    Debug.Log("_ufpTransform:::" + _ufpTransform.forward.ToVector());
        //    //transform.RotateAround(_childObj.position, Vector3.up, Time.deltaTime * RockerSpeed);
        //    return;
        //}
        //else if (_dragging && _directorToRight && !_bTouchMouse) //右遥感
        //{
        //    _rockerControl = ComMoveController.RockerControl.RightControl;
        //    _ufpTransform.RotateAround(_playerTransformObj.position, FPVector.up, FrameSyncManager.DeltaTime * -RockerSpeed);
        //    _ufpTransform.UpdateAllData();

        //    // transform.RotateAround(_childObj.position, Vector3.up, Time.deltaTime * -RockerSpeed);
        //    return;
        //}


        //Debug.Log("_currentAngle:::" + _currentAngle + ",_childObj.eulerAngles.y::" + _childObj.eulerAngles.y
        //    + ",transform.rotation::"+ transform.rotation);

        RaycastHit GroundHitInfo;
        RaycastHit BarrieHitrInfo;
        bool       bGroundInfoFlag  = _motionObj.RayGroundInfo(out GroundHitInfo);
        bool       bBarrierInfoFlag = _motionObj.RayBarrierInfo(_childTransformObj.forward.ToVector(), out BarrieHitrInfo);

        FPVector fpGroundInfoNormal = FPVector.zero;

        if (bGroundInfoFlag)
        {
            fpGroundInfoNormal = GroundHitInfo.normal.ToFPVector();
        }

        if (!_dragging && !_bTouchMouse && _bBeforeDragging)
        {
            _rockerControl = ComMoveController.RockerControl.None;
            return;
        }
        else if (!_dragging)
        {
            if (_bBeforeDragging)  //在这里设置值,为了保证childObj的forward朝向跟摄像机的一致,防止先后差值
            {
                _bBeforeDragging = false;
                return;
            }

            if (!bGroundInfoFlag)  //在空中
            {
                _rockerControl = ComMoveController.RockerControl.AirControl;
                if (_motionObj.bJumpFlag && false)  //这是处理不跟随着对象跳跃的逻辑部分
                {
                    Distance = FPMath.Clamp(Distance - (Input.GetAxis("Mouse ScrollWheel") * MouseScrollWheelSensitivity), DistanceMin, DistanceMax);
                    FPVector DataVec3 = new FPVector(_playerTransformObj.position.x, transform.position.y - Height, _playerTransformObj.position.z);
                    _ufpTransform.position = (_ufpTransform.rotation * new FPVector(.0f, Height, -Distance)) + DataVec3;
                    _ufpTransform.UpdateAllData();
                    return;
                }
            }
            else if (!bBarrierInfoFlag || !_motionObj.JudgetGroundSlope(BarrieHitrInfo.normal))  //有地面接触但前方没有障碍物
            {
                if (!_motionObj.JudgetGroundSlope(GroundHitInfo.normal))
                {
                    _rockerControl  = ComMoveController.RockerControl.OtherControl;
                    _climbOtherWall = false;
                }
                else
                {
                    if (_climbOtherWall && _beforeWallNormalVec3 != fpGroundInfoNormal)  //表示从一面墙跨到另外一面墙
                    {
                        _beforeGroundNormalVec3 = _beforeWallNormalVec3;
                        _beforeWallNormalVec3   = fpGroundInfoNormal;
                    }
                    _rockerControl = ComMoveController.RockerControl.ClimbControl;
                }
            }
            else //有地面接触且前方有障碍物
            {
                _rockerControl = ComMoveController.RockerControl.None;
                _beforeControl = ComMoveController.RockerControl.OtherControl;
                if (!_motionObj.JudgetGroundSlope(GroundHitInfo.normal)) //从地面跨到墙上的情况
                {
                    _beforeGroundNormalVec3 = fpGroundInfoNormal;
                }
                else                                                   //从一面墙跨到另外一面墙的情况
                {
                    _climbOtherWall       = true;
                    _beforeWallNormalVec3 = fpGroundInfoNormal;   //设置这个变量的原因是:有可能检测到障碍物,但是玩家并没有跨越过去
                }
            }
        }

        if (_rockerControl == RockerControl.AirControl)
        {
            Distance = FPMath.Clamp(Distance - (Input.GetAxis("Mouse ScrollWheel") * MouseScrollWheelSensitivity), DistanceMin, DistanceMax);
            _ufpTransform.position = (_ufpTransform.rotation * new FPVector(.0f, Height, -Distance)) + _playerTransformObj.position;
            _ufpTransform.UpdateAllData();
        }
        else if (_rockerControl == RockerControl.OtherControl)
        {
            var quaternion = FPQuaternion.AngleAxis((_currentAngle) + _childTransformObj.transform.eulerAngles.y, FPVector.up);
            Distance = FPMath.Clamp(Distance - (Input.GetAxis("Mouse ScrollWheel") * MouseScrollWheelSensitivity), DistanceMin, DistanceMax);
            _ufpTransform.SetRotation(quaternion);
            // transform.rotation = quaternion;
            FPVector data = (_ufpTransform.rotation * new FPVector(.0f, Height, -Distance));

            _ufpTransform.position = (_ufpTransform.rotation * new FPVector(.0f, Height, -Distance)) + _playerTransformObj.position;
            _ufpTransform.UpdatePosition();
            //Debug.Log("data::"+ data.ToVector()+ ", _ufpTransform.position::::" + _ufpTransform.position.ToVector()
            //    + ",transform::" + transform.position + "::_playerTransformObj.position:" + _playerTransformObj.position.ToVector()
            //    + ",,name::" + _playerTransformObj.gameObject.name);
            _rotation = _ufpTransform.rotation;
            _ufpTransform.UpdateForward();
        }
        else if (_rockerControl == RockerControl.ClimbControl)
        {
            Distance = FPMath.Clamp(Distance - (Input.GetAxis("Mouse ScrollWheel") * MouseScrollWheelSensitivity), DistanceMin, DistanceMax);
            var quaternion = FPQuaternion.AngleAxis((0) + transform.eulerAngles.y, FPVector.up);
            _ufpTransform.position = (_ufpTransform.rotation * new FPVector(.0f, Height, -Distance)) + _playerTransformObj.position;
            _ufpTransform.UpdateAllData();

            FPVector climbForward = _ufpTransform.forward;

            if (_beforeControl == ComMoveController.RockerControl.OtherControl && _beforeGroundNormalVec3 != FPVector.zero)
            {
                FP       tempAngle = FPVector.Angle(_beforeGroundNormalVec3, fpGroundInfoNormal);
                FPVector normal    = FPVector.Cross(_beforeGroundNormalVec3, fpGroundInfoNormal); //叉乘求出法线向量
                                                                                                  //  num *= Mathf.Sign(Vector3.Dot(normal, info.transform.up));  //求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向
                climbForward          = FPQuaternion.AngleAxis((90 - tempAngle), normal) * fpGroundInfoNormal;
                climbForward          = -1 * climbForward;
                _finishWallNormalVec3 = climbForward;
                _beforeControl        = ComMoveController.RockerControl.ClimbControl;
            }

            FP forwardAngle = FPVector.Angle(_finishWallNormalVec3, _ufpTransform.forward);
            if (forwardAngle != 0 && false)  //处理摄像机角度偏转
            {
                //1)调整摄像机的旋转角度
                float    direcFlag  = -1;
                FPVector normalVec3 = FPVector.Cross(_finishWallNormalVec3, _ufpTransform.forward);           //叉乘求出法线向量
                direcFlag    *= FPMath.Sign(Vector3.Dot(normalVec3.ToVector(), _ufpTransform.up.ToVector())); //求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向
                forwardAngle *= direcFlag;

                FPVector beforeForward = _ufpTransform.forward;
                FPVector forward       = FPQuaternion.AngleAxis(forwardAngle, _ufpTransform.up) * _ufpTransform.forward;
                //   Debug.Log("_ufpTransform.forward::" + _ufpTransform.forward.ToVector() + ",forward::" + forward.ToVector()
                //        + "forwardAngle:::" + forwardAngle.AsFloat() + ",forward1111::" + forward);
                float quaternionSpeed = 0.003f;
                if (!_bTouchMouse)
                {
                    quaternionSpeed = 0.03f;
                }
                if (beforeForward != forward)
                {
                    Debug.Log("LookRotation(forward):::" + FPQuaternion.LookRotation(forward) + ",_rotation::" + _rotation + ",unity::" + Quaternion.LookRotation(forward.ToVector()));

                    _rotation = FPQuaternion.Slerp(_rotation, FPQuaternion.LookRotation(forward), quaternionSpeed);
                    _ufpTransform.SetRotation(_rotation);
                }
                //   Debug.Log(",forward::"+ forward.ToVector() + ",_ufpTransform.forward::" + _ufpTransform.forward.ToVector());
                //2)调整人物的旋转角度
                if (!_climbOtherWall)  // 这是从地面爬到墙得处理,如果是从一面墙爬到另外一面墙,镜头不做转换
                {
                    Debug.Log("beforeForward:::" + beforeForward.ToVector() + ",_ufpTransform.forward::" + _ufpTransform.forward.ToVector());
                    _offsetAngle = FPVector.Angle(beforeForward, _ufpTransform.forward) * direcFlag;
                    _avatarObj.ChangeAvaterForward(_offsetAngle);
                }
            }
        }

        Debug.DrawLine(_ufpTransform.position.ToVector(), _playerTransformObj.transform.position, Color.red);

        if (_rockerControl == RockerControl.OtherControl ||
            _rockerControl == RockerControl.ClimbControl)
        {
            //看是否有障碍物
            FPVector directionTarget = (_ufpTransform.position - _ufpTransform.ChangeVec3ToTSVec(_rayPointObj.position)).normalized;
            FP       distance        = FPVector.Distance(_ufpTransform.position, _ufpTransform.ChangeVec3ToTSVec(_rayPointObj.position));
            if (distance > Distance)
            {
                _ufpTransform.Translate(directionTarget * (distance - Distance));
                _ufpTransform.UpdateRotationAndPosition();
            }

            //  Debug.DrawRay(_rayPointObj.position, directionTarget * Distance, Color.black);
            int        layerMask = LayerMask.GetMask(Layers.Render);
            RaycastHit info;
            if (Physics.Raycast(_rayPointObj.position, directionTarget.ToVector(), out info, Distance.AsFloat(), layerMask))  //如果
            {
                //   Debug.Log("info.name::" + info.transform.name);
                if (info.transform.name != transform.name /*&& info.transform.tag != Tags.Ground*/)
                {
                    _ufpTransform.SetPosition(_ufpTransform.ChangeVec3ToTSVec(info.point));
                    //transform.position = info.point;
                }
                if (_rockerControl == RockerControl.OtherControl)
                {
                    _beforeControl = RockerControl.OtherControl;
                }
            }
        }
    }
Beispiel #6
0
    public void ApplyForces(MoveInfo move)
    {
        if (freeze)
        {
            return;
        }

        controlScript.normalizedJumpArc = (Fix64)1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2));


        Fix64 appliedFriction = (moveDirection != 0 || controlScript.myInfo.physics.highMovingFriction) ?
                                UFE.config.selectedStage._groundFriction : controlScript.myInfo.physics._friction;


        if (move != null && move.ignoreFriction)
        {
            appliedFriction = 0;
        }

        if (controlScript.activePullIn != null)
        {
            worldTransform.position = FPVector.Lerp(worldTransform.position,
                                                    controlScript.activePullIn.position,
                                                    UFE.fixedDeltaTime * controlScript.activePullIn.speed);

            if (controlScript.activePullIn.forceStand && !IsGrounded())
            {
                ForceGrounded();
            }

            if (FPVector.Distance(controlScript.activePullIn.position, worldTransform.position) <= controlScript.activePullIn._targetDistance ||
                controlScript.currentSubState != SubStates.Stunned)
            {
                controlScript.activePullIn = null;
            }
        }
        else
        {
            if (!IsGrounded())
            {
                appliedFriction = 0;
                if (verticalForce == 0)
                {
                    verticalForce = -.1;
                }
            }

            if (horizontalForce != 0 && !isTakingOff)
            {
                if (horizontalForce > 0)
                {
                    horizontalForce -= appliedFriction * UFE.fixedDeltaTime;
                    horizontalForce  = FPMath.Max(0, horizontalForce);
                }
                else if (horizontalForce < 0)
                {
                    horizontalForce += appliedFriction * UFE.fixedDeltaTime;
                    horizontalForce  = FPMath.Min(0, horizontalForce);
                }

                Fix64 leftCameraBounds  = opWorldTransform.position.x - (UFE.config.cameraOptions._maxDistance / 2);
                Fix64 rightCameraBounds = opWorldTransform.position.x + (UFE.config.cameraOptions._maxDistance / 2);

                bool bouncingOnCamera = false;
                if (controlScript.currentHit != null &&
                    controlScript.currentHit.bounceOnCameraEdge &&
                    (worldTransform.position.x <= leftCameraBounds ||
                     worldTransform.position.x >= rightCameraBounds))
                {
                    bouncingOnCamera = true;
                }


                if (wallBounceTimes < UFE.config.wallBounceOptions._maximumBounces &&
                    controlScript.currentSubState == SubStates.Stunned &&
                    controlScript.currentState != PossibleStates.Down &&
                    UFE.config.wallBounceOptions.bounceForce != Sizes.None &&
                    FPMath.Abs(horizontalForce) >= UFE.config.wallBounceOptions._minimumBounceForce &&
                    (worldTransform.position.x <= UFE.config.selectedStage._leftBoundary ||
                     worldTransform.position.x >= UFE.config.selectedStage._rightBoundary || bouncingOnCamera) &&
                    controlScript.currentHit != null && controlScript.currentHit.wallBounce &&
                    !isWallBouncing)
                {
                    if (controlScript.currentHit.overrideForcesOnWallBounce)
                    {
                        if (controlScript.currentHit.resetWallBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (controlScript.currentHit.resetWallBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        Fix64 addedH = -controlScript.currentHit._wallBouncePushForce.x;
                        Fix64 addedV = controlScript.currentHit._wallBouncePushForce.y;

                        AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.wallBounceOptions.bounceForce == Sizes.Small)
                        {
                            horizontalForce /= -1.4;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.Medium)
                        {
                            horizontalForce /= -1.2;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.High)
                        {
                            horizontalForce *= -1;
                        }
                    }

                    wallBounceTimes++;

                    if (verticalForce > 0 || !IsGrounded())
                    {
                        if (moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                        {
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.airWallBounce.name;
                        }
                    }
                    else
                    {
                        if (controlScript.currentHit.knockOutOnWallBounce)
                        {
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounceKnockdown);
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounceKnockdown.name;
                        }
                        else
                        {
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounce);
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounce.name;
                        }
                    }

                    if (UFE.config.wallBounceOptions.bouncePrefab != null)
                    {
                        GameObject pTemp = UFE.SpawnGameObject(UFE.config.wallBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.wallBounceOptions.bounceKillTime * UFE.config.fps));
                        pTemp.transform.rotation = UFE.config.wallBounceOptions.bouncePrefab.transform.rotation;
                        if (UFE.config.wallBounceOptions.sticky)
                        {
                            pTemp.transform.parent = transform;
                        }
                        //pTemp.transform.localPosition = Vector3.zero;
                    }

                    if (UFE.config.wallBounceOptions.shakeCamOnBounce)
                    {
                        controlScript.shakeCameraDensity = UFE.config.wallBounceOptions._shakeDensity;
                    }

                    UFE.PlaySound(UFE.config.wallBounceOptions.bounceSound);
                    isWallBouncing = true;
                }

                worldTransform.Translate((horizontalForce * UFE.fixedDeltaTime), 0, 0);
            }

            if (move == null || (move != null && !move.ignoreGravity))
            {
                if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0)
                {
                    verticalForce -= appliedGravity * UFE.fixedDeltaTime;
                    worldTransform.Translate((moveDirection * UFE.fixedDeltaTime) * controlScript.myInfo.physics._jumpDistance, (verticalForce * UFE.fixedDeltaTime), 0);
                }
                else if (verticalForce < 0 &&
                         IsGrounded() &&
                         controlScript.currentSubState != SubStates.Stunned)
                {
                    verticalForce = 0;
                }
            }
        }

        Fix64 minDist = opWorldTransform.position.x - UFE.config.cameraOptions._maxDistance;
        Fix64 maxDist = opWorldTransform.position.x + UFE.config.cameraOptions._maxDistance;

        worldTransform.position = new FPVector(FPMath.Clamp(worldTransform.position.x, minDist, maxDist), worldTransform.position.y, worldTransform.position.z);

        worldTransform.position = new FPVector(
            FPMath.Clamp(worldTransform.position.x,
                         UFE.config.selectedStage._leftBoundary,
                         UFE.config.selectedStage._rightBoundary),
            FPMath.Max(worldTransform.position.y, UFE.config.selectedStage._groundHeight),
            worldTransform.position.z);

        if (controlScript.currentState == PossibleStates.Down)
        {
            return;
        }

        if (IsGrounded() && controlScript.currentState != PossibleStates.Down)
        {
            if (verticalTotalForce != 0)
            {
                if (groundBounceTimes < UFE.config.groundBounceOptions._maximumBounces &&
                    controlScript.currentSubState == SubStates.Stunned &&
                    UFE.config.groundBounceOptions.bounceForce != Sizes.None &&
                    verticalForce <= -UFE.config.groundBounceOptions._minimumBounceForce &&
                    controlScript.currentHit.groundBounce)
                {
                    if (controlScript.currentHit.overrideForcesOnGroundBounce)
                    {
                        if (controlScript.currentHit.resetGroundBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (controlScript.currentHit.resetGroundBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        Fix64 addedH = controlScript.currentHit._groundBouncePushForce.x;
                        Fix64 addedV = controlScript.currentHit._groundBouncePushForce.y;

                        AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.groundBounceOptions.bounceForce == Sizes.Small)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 2.4), 0), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.Medium)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 1.8), 0), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.High)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 1.2), 0), 1);
                        }
                    }

                    groundBounceTimes++;

                    if (!isGroundBouncing)
                    {
                        controlScript.stunTime += airTime + UFE.config.knockDownOptions.air._knockedOutTime;

                        if (moveSetScript.basicMoves.groundBounce.animMap[0].clip != null)
                        {
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.groundBounce.name;
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.groundBounce);
                        }

                        if (UFE.config.groundBounceOptions.bouncePrefab != null)
                        {
                            GameObject pTemp = UFE.SpawnGameObject(UFE.config.groundBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.groundBounceOptions.bounceKillTime * UFE.config.fps));
                            pTemp.transform.rotation = UFE.config.groundBounceOptions.bouncePrefab.transform.rotation;
                            if (UFE.config.groundBounceOptions.sticky)
                            {
                                pTemp.transform.parent = transform;
                            }
                            //pTemp.transform.localPosition = Vector3.zero;
                        }
                        if (UFE.config.groundBounceOptions.shakeCamOnBounce)
                        {
                            controlScript.shakeCameraDensity = UFE.config.groundBounceOptions._shakeDensity;
                        }
                        UFE.PlaySound(UFE.config.groundBounceOptions.bounceSound);
                        isGroundBouncing = true;
                    }
                    return;
                }
                verticalTotalForce          = 0;
                airTime                     = 0;
                moveSetScript.totalAirMoves = 0;
                currentAirJumps             = 0;

                BasicMoveInfo airAnimation  = null;
                string        downAnimation = "";

                isGroundBouncing  = false;
                groundBounceTimes = 0;

                Fix64 animationSpeed = 0;
                Fix64 delayTime      = 0;
                if (controlScript.currentMove != null && controlScript.currentMove.hitAnimationOverride)
                {
                    return;
                }
                if (controlScript.currentSubState == SubStates.Stunned)
                {
                    if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airRecovery.name))
                    {
                        controlScript.stunTime     = 0;
                        controlScript.currentState = PossibleStates.Stand;
                    }
                    else
                    {
                        controlScript.stunTime = UFE.config.knockDownOptions.air._knockedOutTime + UFE.config.knockDownOptions.air._standUpTime;

                        // Hit Clips
                        if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitKnockBack.name) &&
                            moveSetScript.basicMoves.getHitKnockBack.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.getHitKnockBack;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitHighKnockdown.name) &&
                                 moveSetScript.basicMoves.getHitHighKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitHighKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.high._knockedOutTime + UFE.config.knockDownOptions.high._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitMidKnockdown.name) &&
                                 moveSetScript.basicMoves.getHitMidKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitMidKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.highLow._knockedOutTime + UFE.config.knockDownOptions.highLow._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitSweep.name) &&
                                 moveSetScript.basicMoves.getHitSweep.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitSweep;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.sweep._knockedOutTime + UFE.config.knockDownOptions.sweep._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitCrumple.name) &&
                                 moveSetScript.basicMoves.getHitCrumple.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.getHitCrumple;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);

                            // Stage Clips
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.standingWallBounceKnockdown.name) &&
                                 moveSetScript.basicMoves.standingWallBounceKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.standingWallBounceKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airWallBounce.name) &&
                                 moveSetScript.basicMoves.airWallBounce.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.airWallBounce;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime;

                            // Fall Clips
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromAirHit.name) &&
                                 moveSetScript.basicMoves.fallingFromAirHit.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.fallingFromAirHit;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromGroundBounce.name) &&
                                 moveSetScript.basicMoves.fallingFromGroundBounce.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.fallingFromGroundBounce;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else
                        {
                            if (moveSetScript.basicMoves.fallDown.animMap[0].clip == null)
                            {
                                Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit");
                            }

                            airAnimation  = moveSetScript.basicMoves.fallDown;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 1);
                        }

                        controlScript.currentState = PossibleStates.Down;
                    }
                }
                else if (controlScript.currentState != PossibleStates.Stand)
                {
                    if (moveSetScript.basicMoves.landing.animMap[0].clip != null &&
                        (controlScript.currentMove == null ||
                         (controlScript.currentMove != null && controlScript.currentMove.cancelMoveWheLanding)))
                    {
                        controlScript.isAirRecovering = false;
                        airAnimation  = moveSetScript.basicMoves.landing;
                        moveDirection = 0;
                        isLanding     = true;
                        controlScript.KillCurrentMove();
                        delayTime = (Fix64)controlScript.myInfo.physics.landingDelay / (Fix64)UFE.config.fps;
                        UFE.DelaySynchronizedAction(ResetLanding, delayTime);

                        if (airAnimation.autoSpeed)
                        {
                            animationSpeed = moveSetScript.GetAnimationLength(airAnimation.name) / delayTime;
                        }
                    }

                    if (controlScript.currentState != PossibleStates.Crouch)
                    {
                        controlScript.currentState = PossibleStates.Stand;
                    }
                }

                if (airAnimation != null)
                {
                    if (downAnimation != "")
                    {
                        moveSetScript.PlayBasicMove(airAnimation, downAnimation);
                    }
                    else
                    {
                        moveSetScript.PlayBasicMove(airAnimation);
                    }

                    if (animationSpeed != 0)
                    {
                        moveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed);
                    }
                }
            }

            if (controlScript.currentSubState != SubStates.Stunned &&
                !controlScript.isBlocking && !controlScript.blockStunned &&
                move == null &&
                !isTakingOff &&
                !isLanding &&
                controlScript.currentState == PossibleStates.Stand)
            {
                if (moveDirection > 0 && controlScript.mirror == -1 ||
                    moveDirection < 0 && controlScript.mirror == 1)
                {
                    if (moveSetScript.basicMoves.moveForward.animMap[0].clip == null)
                    {
                        Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward");
                    }
                    if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveForward.name))
                    {
                        moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveForward);
                    }
                }
                else if (moveDirection > 0 && controlScript.mirror == 1 ||
                         moveDirection < 0 && controlScript.mirror == -1)
                {
                    if (moveSetScript.basicMoves.moveBack.animMap[0].clip == null)
                    {
                        Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back");
                    }
                    if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveBack.name))
                    {
                        moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveBack);
                    }
                }
            }
        }
        else if (verticalForce > 0 || !IsGrounded())
        {
            if (move != null && controlScript.currentState == PossibleStates.Stand)
            {
                controlScript.currentState = PossibleStates.NeutralJump;
            }
            if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1)
            {
                if (isGroundBouncing)
                {
                    return;
                }

                if (moveDirection == 0)
                {
                    controlScript.currentState = PossibleStates.NeutralJump;
                }
                else
                {
                    if (moveDirection > 0 && controlScript.mirror == -1 ||
                        moveDirection < 0 && controlScript.mirror == 1)
                    {
                        controlScript.currentState = PossibleStates.ForwardJump;
                    }

                    if (moveDirection > 0 && controlScript.mirror == 1 ||
                        moveDirection < 0 && controlScript.mirror == -1)
                    {
                        controlScript.currentState = PossibleStates.BackJump;
                    }
                }

                BasicMoveInfo airAnimation = moveSetScript.basicMoves.jumpStraight;
                if (controlScript.currentSubState == SubStates.Stunned)
                {
                    if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                    {
                        airAnimation = moveSetScript.basicMoves.airWallBounce;
                    }
                    else if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null &&
                             FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce &&
                             UFE.config.comboOptions._knockBackMinForce > 0)
                    {
                        airAnimation = moveSetScript.basicMoves.getHitKnockBack;
                        airTime     *= (Fix64)2;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null)
                        {
                            Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air");
                        }

                        airAnimation = moveSetScript.basicMoves.getHitAir;
                    }
                    if (overrideStunAnimation != null)
                    {
                        airAnimation = overrideStunAnimation;
                    }
                }
                else if (controlScript.isAirRecovering &&
                         (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null))
                {
                    airAnimation = moveSetScript.basicMoves.airRecovery;
                }
                else
                {
                    if (moveSetScript.basicMoves.jumpForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump)
                    {
                        airAnimation = moveSetScript.basicMoves.jumpForward;
                    }
                    else if (moveSetScript.basicMoves.jumpBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump)
                    {
                        airAnimation = moveSetScript.basicMoves.jumpBack;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.jumpStraight.animMap[0].clip == null)
                        {
                            Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight");
                        }

                        airAnimation = moveSetScript.basicMoves.jumpStraight;
                    }
                }

                if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    moveSetScript.PlayBasicMove(airAnimation);

                    if (airAnimation.autoSpeed)
                    {
                        moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }
                }
            }
            else if (move == null && verticalForce / verticalTotalForce <= 0)
            {
                BasicMoveInfo airAnimation = moveSetScript.basicMoves.fallStraight;
                if (isGroundBouncing && moveSetScript.basicMoves.fallingFromGroundBounce.animMap[0].clip != null)
                {
                    airAnimation = moveSetScript.basicMoves.fallingFromGroundBounce;
                }
                else if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                {
                    airAnimation = moveSetScript.basicMoves.airWallBounce;
                }
                else
                {
                    if (controlScript.currentSubState == SubStates.Stunned)
                    {
                        if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null &&
                            FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce &&
                            UFE.config.comboOptions._knockBackMinForce > 0)
                        {
                            airAnimation = moveSetScript.basicMoves.getHitKnockBack;
                        }
                        else
                        {
                            airAnimation = moveSetScript.basicMoves.getHitAir;
                            if (moveSetScript.basicMoves.fallingFromAirHit.animMap[0].clip != null)
                            {
                                airAnimation = moveSetScript.basicMoves.fallingFromAirHit;
                            }
                            else if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null)
                            {
                                Debug.LogError("Air Juggle animation not found! Make sure you have it set on Character -> Basic Moves -> Air Juggle");
                            }
                        }
                        if (overrideStunAnimation != null)
                        {
                            airAnimation = overrideStunAnimation;
                        }
                    }
                    else if (controlScript.isAirRecovering &&
                             (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null))
                    {
                        airAnimation = moveSetScript.basicMoves.airRecovery;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.fallForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump)
                        {
                            airAnimation = moveSetScript.basicMoves.fallForward;
                        }
                        else if (moveSetScript.basicMoves.fallBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump)
                        {
                            airAnimation = moveSetScript.basicMoves.fallBack;
                        }
                        else
                        {
                            if (moveSetScript.basicMoves.fallStraight.animMap[0].clip == null)
                            {
                                Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight");
                            }

                            airAnimation = moveSetScript.basicMoves.fallStraight;
                        }
                    }
                }

                if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    moveSetScript.PlayBasicMove(airAnimation);

                    if (airAnimation.autoSpeed)
                    {
                        moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }
                }
            }
        }
        if (horizontalForce == 0 && verticalForce == 0)
        {
            moveDirection = 0;
        }
    }