AI extentsion Resource
by Firas · in Technical Issues · 11/12/2004 (3:35 am) · 2 replies
I have implement this resource and also Ace update, It's perfect on terrain but the problem is if the AIPlayer run after you trying to kill you and you go behind a building lets say a house, the AIPlayer can't avoid that building or house to reach you.
I think we should solve this problem "Avoiding obstacles" , I'm trying to do that but I'm afraid that I can't do it just by myself so I need some support here from anyone interesting on this, like Ace or anyone.
Now I'm trying to understand the sorce code on aiplayer.cc
agine you support guys are most welcome.
Regrads
I think we should solve this problem "Avoiding obstacles" , I'm trying to do that but I'm afraid that I can't do it just by myself so I need some support here from anyone interesting on this, like Ace or anyone.
Now I'm trying to understand the sorce code on aiplayer.cc
agine you support guys are most welcome.
Regrads
About the author
#2
I wanted to say thanks.
I used part of your sidestep routine in a script of mine that I developed for a guard bot. I'm not going to quite the same extent you are with my guy, I'm just having him pick a random spot nearby and then attempt to move toward it.
Crude, but for a simple AI bot it works relatively well.
As a suggestion to you, you could have your bot check with three rays as he moves, one to the left at an angle, one ahead and one to the right at an angle.
Then have the bot keep track of which direction was open the furthest most recently left or right if his motion is obstructed. That way you would know which way was most likely clear.
11/25/2004 (8:38 pm)
Hey Katrina,I wanted to say thanks.
I used part of your sidestep routine in a script of mine that I developed for a guard bot. I'm not going to quite the same extent you are with my guy, I'm just having him pick a random spot nearby and then attempt to move toward it.
Crude, but for a simple AI bot it works relatively well.
As a suggestion to you, you could have your bot check with three rays as he moves, one to the left at an angle, one ahead and one to the right at an angle.
Then have the bot keep track of which direction was open the furthest most recently left or right if his motion is obstructed. That way you would know which way was most likely clear.
Katrina Rose
Default Studio Name
I have my bits avoiding obstacles and I also implimented a Field of View in the AIPlayer.cc. It's quite easy actually. All you have to do is shoot a raycast from there eye vector and if it hits something have the bot move in the X axis either left or right (The Y axis for the bots always points forward). I have them checking the distance between them and the obstacle and when the are within 20 of it I then have them slide left or right. Here is the code:
function botCollisionAvoid() { for (%count = 0; %count < $botCounter;%count++) { %botPathNodes = $bots[%count].Path.getCount(); if (%botPathNodes < 15 && %botPathNodes > 1) { for (%height = 98.0;%height < 101.0;%height = %height + 0.40) { %xfrm = $bots[%count].getEyeTransform(); %lx = getword(%xfrm, 0); %ly = getword(%xfrm, 1); %lz = getword(%xfrm, 2); %rx = getword(%xfrm, 3); %ry = getword(%xfrm, 4); %rz = getword(%xfrm, 5); %node = $bots[%count].Path.getObject($bots[%count].CurrentNode); %mask = $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::StaticShapeObjectType; %newLoc = $bots[%count].getTransform(); %newLoc = setWord(%newLoc, 3, %height); %scanTarg = ContainerRayCast(%newLoc,%node.getTransform(),%mask); %botNode = $bots[%count].currentNode; %botPosition = $bots[%count].getTransform(); if ($bots[%count].botStop $= "0") { if(%scanTarg != 0 && vectorDist(%botPosition, %scanTarg.getTransform()) < 20) { sideStep(%count, %ly); } else { $bots[%count].moveToNode(%botNode); } } } } } }function sideStep(%botNum, %curY) { %xrand = getRandom(-15,50); %newLoc = $bots[%botNum].getTransform(); //adjust the x pos too by 80% of the bot's index number %newLoc = setWord(%newLoc, 0, (getWord(%newLoc, 0) + (%xrand))); %newLoc = setWord(%newLoc, 1, (getWord(%newLoc, 1) + (%curY))); $bots[%botNum].setMoveDestination(%newLoc); $bots[%botNum].clearAim(); }I hope this helps. I wanted to do this in AIPlayer.cc, but I don't know enough about C++ to translate this.
Marrion