ah yes, sorry i missed the MoveForward command is also missing
Quote: "AIEntityGoToPosition(EntObjNo,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)
MoveForward(e,AIGetEntitySpeed(g_Entity[e]['obj'])*2)
SetRotation(e,0,AIGetEntityAngleY(g_Entity[e]['obj']),0)
AISetEntityPosition(g_Entity[e]['obj'],GetEntityPositionX(e),GetEntityPositionY(e),GetEntityPositionZ(e))"
also note that the RotateToPlayer(e) no longer works with the AI (in my experience) as you now set the rotation based on the capsule rotation... i guess it's possible to skip that but it would likely lead to weird effects - better to directly update the rotation in the SetRotation() call,
i have a function to get the angle to a point
function AngleToPoint(e,x,z)
if g_Entity[e] ~= nil and x > 0 and z > 0 then
local destx = x - g_Entity[e]['x']
local destz = z - g_Entity[e]['z']
local angle = math.atan2(destx,destz)
angle = angle * (180.0 / math.pi)
if angle < 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
--SetRotation(e,0,angle,0)
return angle
end
end
so you change the SetRotation to look like this
Quote: "SetRotation(e,0,AngleToPoint(e,g_PlayerPosX,g_PlayerPosZ),0)"
so the end result looks like this
function test_main(e)
if g_Entity[e]['activated'] == 1 then
AIObjNo = g_Entity[e]['obj']
CharacterControlManual(e)
ai_bot_state[e] = ai_state_move
SetAnimation(1)
LoopAnimation(e)
SetAnimationSpeedModulation(e,1.0)
SetActivated(e,2)
elseif g_Entity[e]['activated'] == 2 then
if ai_bot_state[e] == ai_state_move then
AIEntityGoToPosition(EntObjNo,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)
MoveForward(e,AIGetEntitySpeed(g_Entity[e]['obj']))
SetRotation(e,0,AngleToPoint(e,g_PlayerPosX,g_PlayerPosZ),0)
AISetEntityPosition(g_Entity[e]['obj'],GetEntityPositionX(e),GetEntityPositionY(e),GetEntityPositionZ(e))
end
end
end
function AngleToPoint(e,x,z)
if g_Entity[e] ~= nil and x > 0 and z > 0 then
local destx = x - g_Entity[e]['x']
local destz = z - g_Entity[e]['z']
local angle = math.atan2(destx,destz)
angle = angle * (180.0 / math.pi)
if angle < 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
--SetRotation(e,0,angle,0)
return angle
end
end
p.s. from your code i assume you are using zones and spawn at start = no? i dont think it will work without due to the activated state checks