Exemplo n.º 1
0
        protected Vector3 NewWalkSpeed()
        {
            float _res_spd;

            _res_spd = LerpFloat(LBMath.TruncFloat(RBSpeedVectorFlat.magnitude), desired_speed, movement_accel, Time.fixedDeltaTime);
            return(_res_spd * target_rigidbody.transform.forward - FloorNormal * 0.1f * _res_spd);
        }
Exemplo n.º 2
0
 protected bool bWantsToStand()
 {
     if (bHasFloor && LBMath.TruncFloat(desired_speed) <= MAXIDLETHRESH)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 protected bool bIsStanding()
 {
     if (bHasFloor && LBMath.TruncFloat(RBSpeedVectorFlat.magnitude) <= MAXIDLETHRESH)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 4
0
        protected void ProcessWalkState()
        {
            Vector3    new_up, new_forward, floor_fwd;
            Quaternion new_rotation;

            //Quaternion get_new_dir()
            //{
            //    return Quaternion.FromToRotation(Vector3.up, FloorNormal) * Quaternion.LookRotation(Quaternion.Euler(0, desired_direction, 0) * Vector3.forward, Vector3.up);
            //}

            //Vector3 get_new_speed()
            //{
            //    float _res_spd;
            //    _res_spd = LerpFloat(LBMath.TruncFloat(RBSpeedVectorFlat.magnitude), desired_speed, movement_accel, Time.fixedDeltaTime);
            //    return _res_spd * target_rigidbody.transform.forward - FloorNormal * 0.1f * _res_spd;
            //}

            //void walk()
            //{
            //    float res_spd;
            //    res_spd = LerpFloat(LBMath.TruncFloat(RBSpeedVectorFlat.magnitude), desired_speed, movement_accel, Time.fixedDeltaTime);
            //    current_direction = LerpFloat(current_direction, desired_direction, rotation_speed, Time.fixedDeltaTime);
            //    //target_rigidbody.transform.up = FloorNormal;
            //    //target_rigidbody.transform.rotation = target_rigidbody.transform.rotation * Quaternion.Euler(0, current_direction, 0);
            //    new_rotation = Quaternion.FromToRotation(Vector3.up, FloorNormal) * Quaternion.LookRotation(Quaternion.Euler(0, desired_direction, 0) * Vector3.forward, Vector3.up); //Quaternion.Euler(0, desired_direction, 0);
            //    target_rigidbody.transform.rotation = new_rotation;
            //    target_rigidbody.velocity = res_spd * target_rigidbody.transform.forward - FloorNormal * 0.1f * res_spd;
            //    UpdateSlider(0, speed_restraint.Percentage(LBMath.TruncFloat(RBSpeedVectorFlat.magnitude)));
            //}

            //void walk()
            //{
            //    target_rigidbody.transform.rotation = NewRotation();
            //    target_rigidbody.velocity = NewWalkSpeed();
            //    UpdateSlider(0, speed_restraint.Percentage(LBMath.TruncFloat(RBSpeedVectorFlat.magnitude)));
            //}

            //if (bHasFloor)
            //{
            //    if (bIsWalking())
            //    {
            //        if (bCanWalkInDirection(NewWalkDirection())) // if we can walk the direction (no walls, etc)
            //        {
            //            if (bWantsToWalk()) // if we're currently walking and still want to walk
            //            {
            //                walk(); // accelerating
            //            }
            //            else // we may need to perform full stop
            //            {
            //                walk(); // braking is handled in the same func
            //            }
            //        }
            //        else // if we hit blocking a wall
            //        {
            //            SwitchState(STAND);
            //        }
            //    }
            //    else
            //    {
            //        if (bWantsToWalk()) // should accelerate from static state
            //        {
            //            if (!bHasBlockingWall())
            //                walk(); // we're accelerating now
            //            else
            //                SwitchState(STAND);
            //            // current_direction != desired_direction -- can start moveing in opposite direction (need special state)!
            //        }
            //        else
            //        {
            //            if (current_direction != desired_direction) // should start turn in place
            //            {
            //                SwitchState(TURNINPLACE);
            //            }
            //            else
            //            {
            //                SwitchState(STAND);
            //            }
            //        }
            //    }
            //}
            //else
            //{
            //    SwitchState(NOFLOOR);
            //}

            target_rigidbody.transform.rotation = Quaternion.RotateTowards(target_rigidbody.transform.rotation, NewRotation(), RotationSpeed);
            target_rigidbody.velocity           = NewWalkSpeed();
            UpdateSlider(0, speed_restraint.Percentage(LBMath.TruncFloat(RBSpeedVectorFlat.magnitude)));
        }