/** * 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)); }
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); }
public static float Sign(float A) { return(UKismetMathLibrary.SignOfFloat(A)); }
public static int Sign(int A) { return(UKismetMathLibrary.SignOfInteger(A)); }
public static float Min(float A, float B) { return(UKismetMathLibrary.FMin(A, B)); }
public static new int Clamp(int A, int min, int max) { return(UKismetMathLibrary.Clamp(A, max, min)); }
public static float Clamp(float A, float min, float max) { return(UKismetMathLibrary.FClamp(A, max, min)); }
public static float Angle(FVector2D A, FVector2D B) { float cosa = (A | B) / (A.Size() * B.Size()); return(UKismetMathLibrary.Acos(cosa)); }
/** * 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))); }
/** * 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)); }