Game Development Community

Sporadic aiPlayer setMoveDestination Issue

by Billy Fisher · in Technical Issues · 11/26/2004 (9:22 pm) · 6 replies

Hey,

I am using the AIPlayer class supplied with Torque 1.3 and in my project directory am using the same aiPlayer.cs as is provided with example.fps in the Torque 1.3 package I installed (windows binary package, not CVS). My problem is that when I execute setMoveDestination(localclientconnection.player.getPosition()); of an AIPlayer in the mission the bot moves around sporadically instead of straight towards the player like I'd expect. The two most common interesting behaviors I get is either the AIPlayer circles the player object or doesn't move much at all and spins around while moving little forever.

I have noticed that this only happens after aiPlayer.cs.dso is created. Deleting aiPlayer.cs.dso causes setMoveDestination to operate perfectly for the one instance of the game that is run that causes aiPlayer.cs.dso to be re-created. After shutting down the game and starting back up the above problem reappears until I delete the aiPlayer.cs.dso file again to correct the issue.

I am still pretty new to the engine so I am not sure what the significance of this pattern is that I found and am hoping someone else may have some clues. I have noticed that I cannot re-create this issue when I run the example.fps game supplied with the Torque 1.3 package.

Would anyone have any ideas as to what I am doing wrong to get sporadic behavior when executing setMoveDestination on an AIPlayer object while aiplayer.cs.dso exists?

Thanks in advance,
Billy

About the author

Recent Threads


#1
11/27/2004 (3:41 am)
I've seen this happen. It has to do with the callback OnReachDestination that isn't called correctly.

There are some threads that deal with this problem.
#2
11/27/2004 (8:38 pm)
Hey Bruno,

Thanks a lot for pointing that out! I realized that the way I had my AIPlayer setup none of the callbacks were being made at all. When they are made everything runs great.

Thanks,
Billy
#3
11/27/2004 (9:29 pm)
Glad you got it fixed. I've also seen the player go nuts and spin wildly when his aim location is set to the movelocation. Upon arrival at the location, the bot will try to spin and stare at his feet. This can be pretty entertaining to watch, but aggravating.

Also, if you're looking for some AI code to run I threw together a couple of resources that add some quick AI into the game.

You can check them out here:

www.garagegames.com/index.php?sec=mg&mod=resource&page=result&qtm=holcomb
#4
11/28/2004 (3:10 pm)
Hey Mark,

Thanks for the heads up on the aim location issue :) Yeah actually I absolutely LOVE your newaiplayer.cs (artificial intelligence beginning) example that you provided. For me it was EXTREMELY handy in getting the aiPlayers to chase the player down and attack once they reach them (more of melee like combat). What really helped me was the code for looking for nearby players and the function to return the distance between a player and the AIPlayer (close distance to initiate melee combat in the game I'm working on). Without that resource I'd still be working on getting the AIPlayers to determine when to attack the player and track them down upon getting close enough to them :) That resource saved me a lot of time in getting started with the AI code.

Thanks for such awesome resources,
Billy
#5
11/28/2004 (3:55 pm)
Thanks for the kind words, but I have to admit that a lot of the line of sight code and such came from some other resources.

Another thing to look out for on the aim issue is the bot trying to attack the players feet and not their head. You have to correct for this by altering the target's position.

I'm using this

%obj.setAimLocation(VectorAdd(%tgt.player.getPosition(),"0 0 2.0"));

to get the bot to aim 2 units above the ground position of the target to get body/head shots.

If you're working on close combat, the AIGuard unit is probably going to be a better fit for you. It's easier to modify - imho. Plus it already has the code to get the unit to close in on the target.

In your case, if you're using melee weapons all you'd have to do is keep the detect distance high and then set the ignore distance to a real short range. That would cause the AIGuard unit to keep closing in until they got up close and personal before attacking and swinging their sword or such.

So you might check into trying that. Plus AIGuard is more customizable for future changes.
#6
11/28/2004 (4:25 pm)
Hey Mark,

Coolness :) Yeah currently on my project I am still prototyping and roughing out a great many things to see how the gameplay is going to work. When I start working on smaller details I will take a look at your AIGuard resource as well as I start to work on making the AIPlayers smarter (they're pretty dumb right now but at least they chase and attack the player now, lol).

Yeah, I saw that some of the functions came from other resources, but you know it was great to see those resources merged into one good working example so I still very much appreciated the resource, it was very helpful in getting me started and I didn't have to dig forever to see how simple AI could work :)

Thanks & Take Care,
Billy