跳到主要内容

NPC_SetAngleToPos

注意

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

描述

旋转 NPC,使其朝向特定的世界坐标位置。

参数说明
npcidNPC 的 ID。
Float:x目标位置的 X 坐标。
Float:y目标位置的 Y 坐标。
Float:z目标位置的 Z 坐标。

返回值

如果 NPC 旋转成功,返回true;否则返回false

示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/lookatpos", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "你没有在调试NPC。");

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "无效的NPC。");

new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);

NPC_SetAngleToPos(npcid, x + 3.0, y, z);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d 正朝向 %.2f, %.2f, %.2f", npcid, x + 3.0, y, z);
return 1;
}
return 0;
}

注意事项

注意
  • 计算朝向角度时,仅考虑水平面(X/Y 坐标)。
  • NPC 不会移动;仅执行旋转操作以朝向目标位置。

相关函数