예제 #1
0
        /// <summary>
        /// Move the current kerbal to target.
        /// </summary>
        /// <param name="move"></param>
        /// <param name="speed"></param>
        internal void Move(Vector3d move, float speed)
        {
            #region Move & Rotate Kerbal

            //speed values
            move *= speed;

            //rotate
            if (move != Vector3d.zero)
            {
                if (eva.JetpackDeployed)
                {
                    eva.PackToggle();
                }
                else
                {
                    //rotation
                    Quaternion from   = eva.part.vessel.transform.rotation;
                    Quaternion to     = Quaternion.LookRotation(move, eva.fUp);
                    Quaternion result = Quaternion.RotateTowards(from, to, eva.turnRate);

                    eva.part.vessel.SetRotation(result);

                    Rigidbody rigidbody = null;
                    eva.GetComponentCached <Rigidbody>(ref rigidbody);

                    //move
                    if (rigidbody != null)
                    {
                        RemoveRBAnchor(eva);
                        rigidbody.MovePosition(rigidbody.position + move);
                    }
                }
            }

            #endregion
        }