My issue is that the AIPlayer runs towards a wall and either gets stuck in a corner, or decides to be handicapped and change directions.
How would I go about making the AIPlayer turn away from/follow the wall when isObject(%raycast) is true. I can't seem to find any code that relates to this problem.
function AIPlayer::randomMove(%player,%z)
{
%loc = vectorAdd(%player.getTransform(),getRandom(-25,25) SPC getRandom(-25,25) SPC %z);
%vec = VectorDist(%player.SpawnPos, %player.gettransform());
%EyeVector = %player.getEyeVector();
%EyePoint = %player.getEyePoint();
%Range = 2;
%RangeScale = VectorScale(%EyeVector, %Range);
%RangeEnd = VectorAdd(%EyePoint, %RangeScale);
%raycast = containerRayCast(%eyePoint,%RangeEnd,$TypeMasks::FxBrickObjectType, %player);
if(isObject(%raycast))
{
if(vectorDist(%player.PrevLoc,%player.position) < 2)
{
%player.BotJump();
}
//Make the bot turn here?
}
%player.setMoveDestination(%loc);
}