Game Development Community

Bug with AIPlayer::setAimLocation?

by Robert Garrett · in Torque Game Engine · 07/22/2002 (4:12 pm) · 2 replies

I didn't think this post belonged in the AI forum, since it doesn't really deal with coding AI, but rather a problem I'm having with the Engine. The problem I'm having is that while setAimLocation seems to do just fine with the x and y, it doesn't seem to do anything for the the z axis. My bots shoot at a constant 10 degrees above the horizontal plane regardless of the player's location. Here's how I'm calling it in the script:

%aimPos = $daPlaya.getWorldBoxCenter();
%this.setAimLocation(%aimPos);

I've also tried

%aimPos = $daPlaya.getPosition();

which should make the bot shoot at the player's feet, but it had the exact same result.

I've even gone so far as to add this line of code in the actual function in AIPlayer.cc:

mAimLocation.z = location.z;

thereby ensuring that the 'z' value is getting set, but to no avail. I've seen a couple of isolated posts where poeple have said their bot are shooting over the player's head, but I've never seen an answer. Any ideas?

#1
07/22/2002 (10:12 pm)
I've noticed that, too... but after taking out the setAimLocation() completely, the bots are aiming much better now... I don't know what may be the problem with this function, though... just take it out and try
#2
07/23/2002 (6:31 am)
I've tried that actually, and yes, the end result is better, with the bots shooting along the horizontal plane. Unfortunately, my level has alot of slopes, so it is fairly important that the bot be able to change the pitch of its shot. I've tried commenting out the following line in setMoveDestination():

mAimLocation.z = 0.0f;

but it didn't make a difference. I also replaced it with

mAimLocation.z = location.z;

once again without any result. The conclusion I've come to is that somewhere, somehow, regardless of what you set mAimLocation's "z" value to, it gets reset somewhere else in the engine. I've tried tracking it down, but I've been unsuccessful.