示例#1
0
        private void UpdateAnimation()
        {
            FVector playerVelocity = GetVelocity();
            float   playerSpeedSqr = playerVelocity.SizeSquared();

            // Are we moving or standing still?
            UPaperFlipbook desiredAnimation = playerSpeedSqr > 0.0f ? RunningAnimation : IdleAnimation;

            if (Sprite.GetFlipbook() != desiredAnimation)
            {
                Sprite.SetFlipbook(desiredAnimation);
            }
        }
示例#2
0
        /// <summary>
        /// Interpolate vector from Current to Target. Scaled by distance to Target, so it has a strong start speed and ease out.
        /// </summary>
        public static FVector VInterpTo(FVector current, FVector target, float deltaTime, float interpSpeed)
        {
            // If no interp speed, jump to target value
            if (interpSpeed <= 0.0f)
            {
                return(target);
            }

            // Distance to reach
            FVector dist = target - current;

            // If distance is too small, just set the desired location
            if (dist.SizeSquared() < KindaSmallNumber)
            {
                return(target);
            }

            // Delta Move, Clamp so we do not over shoot.
            FVector deltaMove = dist * FMath.Clamp(deltaTime * interpSpeed, 0.0f, 1.0f);

            return(current + deltaMove);
        }
示例#3
0
        /// <summary>
        /// Generates the 'smallest' (geodesic) rotation between two vectors of arbitrary length.
        /// </summary>
        public static FQuat FindBetweenVectors(FVector vector1, FVector vector2)
        {
            float normAB = FMath.Sqrt(vector1.SizeSquared() * vector2.SizeSquared());

            return(FindBetween_Helper(vector1, vector2, normAB));
        }