根据位置变化改变角度

时间:2016-03-31 01:30:15

标签: scripting

我正在为允许使用自定义脚本的游戏编写场景。 我想使用SetCameraHeading(float in_fAngle)更改摄像机角度,其中: " 0面朝东,90面向北,180面向西,270面向南"。 我做了这样的事情:

//The map size is 150x300:
NWX = 0;
NWY = 300;
NEX = 150;
NEY = 300;
SWX = 0;
SWY = 0;
SEX = 150;
SEY = 0;

Player1NW = GetDistanceFromUnitToPoint("Survivor1", NWX, NWY);
Player1NE = GetDistanceFromUnitToPoint("Survivor1", NEX, NEY);
Player1SW = GetDistanceFromUnitToPoint("Survivor1", SWX, SWY);
Player1SE = GetDistanceFromUnitToPoint("Survivor1", SEX, SEY);

Player1NWDiff = Player1NWOld - Player1NW;
Player1NEDiff = Player1NEOld - Player1NE;
Player1SWDiff = Player1SWOld - Player1SW;
Player1SEDiff = Player1SEOld - Player1SE;
//Need to set camera heading here:
SetCameraHeading(Player1CurrentAngle, false);

Player1NWOld = Player1NW;
Player1NEOld = Player1NE;
Player1SWOld = Player1SW;
Player1SEOld = Player1SE;

问题是我不知道如何根据位置变化改变角度(例如,当一个单位行走时,它变为:Player1NWDiff = -0.02,Player1NEDiff = -0.02,Player1SWDiff = 0.04,Player1SEDiff = 0.03等。)

有人知道如何计算它以获得正确的角度(0到360)?

0 个答案:

没有答案