Hey community,
i want to share some code snippets to you because NCsoft changed a little bit in Aion and now i want to share a new Facting to X Y method. ;)
Thanks to PharmerPhale for some help. :)
C# Code
This method gives you the Player Rotation back which the character needs for the new X and Y coordinate. If you want to use it you need to insert your own GetPlayerRotation and your own GetPlayerX and Y. If you dont know how to use the math namespace, try looking at msdn. :)
C++ Code
And thats my C++ version of this. You have to include <math.h> and you have to replace my pCoordX() pCoordY() and pRotation() then it should work for you. :)
I hope I can help some coders. :)
So long,
Unknw0n0x
i want to share some code snippets to you because NCsoft changed a little bit in Aion and now i want to share a new Facting to X Y method. ;)
Thanks to PharmerPhale for some help. :)
C# Code
Code:
private double RotNeeded(float X, float Y) { double faceAngle = Math.Atan2(Y - Player.GetPlayerY(), X - Player.GetPlayerX()); faceAngle = faceAngle * 180 / Math.PI; faceAngle -= 90; if (faceAngle > 180) { faceAngle -= 360; } faceAngle -= 180; if (faceAngle < -180 && faceAngle > -360) { faceAngle += 360; } return faceAngle; }
C++ Code
Code:
double aPlayer::rotationNeed(float X, float Y) { double faceAngle = atan2(Y - pCoordY(), X - pCoordX()); faceAngle = faceAngle * 180 / 3.14159265; faceAngle -= 90; if (faceAngle > 180) faceAngle -= 360; faceAngle -= 180; if (faceAngle < -180 && faceAngle > -360) faceAngle += 360; return faceAngle; }
I hope I can help some coders. :)
So long,
Unknw0n0x