Scripts / AIEntityGoToPosition(EntObjNo,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)

Author
Message
dimoxinil
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location:
Posted: 18th May 2017 13:55 Edited at: 18th May 2017 14:05
Hi everybody!

I have a question about AI ENTITY GO TO POSITION.

I have a enemy in manual mode AISetEntityControl(AIObjNo,0) and I want to move it to the player position or some other position .

In this simple example.

if g_Entity[e]['activated'] == 1 then
AIObjNo = g_Entity[e]['obj']
AISetEntityControl(AIObjNo,0)
ai_bot_state[e] = ai_state_move
SetAnimation(1)
LoopAnimation(e)
SetAnimationSpeedModulation(e,1.0)
SetActivated(e,2)
end

if g_Entity[e]['activated'] == 2 then
if ai_bot_state[e] == ai_state_move then
RotateToPlayer(e)
ai_bot_targetx[e] = g_PlayerPosX
ai_bot_targety[e] = g_PlayerPosY
ai_bot_targetz[e] = g_PlayerPosZ
AIEntityGoToPosition(AIObjNo,ai_bot_targetx[e],ai_bot_targety[e],ai_bot_targetz[e])
end
end

Why isn't he moving?
Did I miss a step here ?
Can the Ai move in manual mode?

Thanks for your time and consideration

P.S
I'm on the GG last update 2017.05.12.


smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th May 2017 14:05 Edited at: 18th May 2017 15:13
edit
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
dimoxinil
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location:
Posted: 18th May 2017 14:17 Edited at: 18th May 2017 14:19
I have still not managed to move the IA but I'm going to experimenting with your explanation.
Thank you very much for the help smallg .


smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th May 2017 15:05 Edited at: 18th May 2017 15:13
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

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


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
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
dimoxinil
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location:
Posted: 18th May 2017 16:39
Okay, all right, now. I get it.

Yes I'm spawn enemies through a trigger activation.
I doing AI testing and trying to understand how the new AI works. But I was absolutely stuck on the Ai move in manual mode.

Thank you very much for your kind attention smallg.


Login to post a reply

Server time is: 2024-04-27 05:00:02
Your offset time is: 2024-04-27 05:00:02