Exemple #1
0
        /**
         * Rotates around axis (0,0,1)
         *
         * @param AngleDeg Angle to rotate (in degrees)
         * @return Rotated Vector
         */
        public FVector2D GetRotated(float AngleDeg)
        {
            float S, C;

            FMath.SinCos(out S, out C, UKismetMathLibrary.DegreesToRadians(AngleDeg));

            float OMC = 1.0f - C;

            return(new FVector2D(
                       C * X - S * Y,
                       S * X + C * Y));
        }
Exemple #2
0
        void Tick(float deltaTime)
        {
            FRotator rot     = pc.GetControlRotation();
            FVector  forward = UKismetMathLibrary.GetForwardVector(new FRotator(0, rot.Yaw, 0));
            FVector  right   = UKismetMathLibrary.GetRightVector(new FRotator(0, rot.Yaw, 0));
            FKey     key     = new FKey();

            key.KeyName = FName.FromString("W");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(forward, 1.0f, false);
            }
            key.KeyName = FName.FromString("S");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(-forward, 1.0f, false);
            }
            key.KeyName = FName.FromString("A");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(-right, 1.0f, false);
            }
            key.KeyName = FName.FromString("D");
            if (pc.IsInputKeyDown(key))
            {
                pc.K2_GetPawn().AddMovementInput(right, 1.0f, false);
            }

            key.KeyName = FName.FromString("J");
            if (pc.IsInputKeyDown(key))
            {
                USkeletalMeshComponent mesh = Cast <USkeletalMeshComponent>(pc.K2_GetPawn().GetComponentByClass(typeof(USkeletalMeshComponent)));
                mesh.GetAnimInstance().Montage_Play(Montage, 1);
            }

            float movex, movey;

            pc.GetInputMouseDelta(out movex, out movey);
            pc.AddYawInput(movex);
            pc.AddPitchInput(movey);
        }
Exemple #3
0
 public static float Sign(float A)
 {
     return(UKismetMathLibrary.SignOfFloat(A));
 }
Exemple #4
0
 public static int Sign(int A)
 {
     return(UKismetMathLibrary.SignOfInteger(A));
 }
Exemple #5
0
 public static float Min(float A, float B)
 {
     return(UKismetMathLibrary.FMin(A, B));
 }
Exemple #6
0
 public static new int Clamp(int A, int min, int max)
 {
     return(UKismetMathLibrary.Clamp(A, max, min));
 }
Exemple #7
0
 public static float Clamp(float A, float min, float max)
 {
     return(UKismetMathLibrary.FClamp(A, max, min));
 }
Exemple #8
0
        public static float Angle(FVector2D A, FVector2D B)
        {
            float cosa = (A | B) / (A.Size() * B.Size());

            return(UKismetMathLibrary.Acos(cosa));
        }
Exemple #9
0
 /**
  * Distance between two 2D points.
  *
  * @param V1 The first point.
  * @param V2 The second point.
  * @return The squared distance between two 2D points.
  */
 public static float Distance(FVector2D V1, FVector2D V2)
 {
     return(UKismetMathLibrary.Sqrt(FVector2D.DistSquared(V1, V2)));
 }
Exemple #10
0
 /**
  * Squared distance between two 2D points.
  *
  * @param V1 The first point.
  * @param V2 The second point.
  * @return The squared distance between two 2D points.
  */
 public static float DistSquared(FVector2D V1, FVector2D V2)
 {
     return(UKismetMathLibrary.Square(V2.X - V1.X) + UKismetMathLibrary.Square(V2.Y - V1.Y));
 }