For a project I need to make use of a number of AI techniques, and I’m stuck on dynamic wander. The purpose of this is to create a circle a certain distance in front of the player’s orientation and then move to that point and repeat. My current code only seems to move the player in all directions instead of just mostly forward.
Your algorithm isn’t correct. You should be using a point on the perimeter of a circle (for 2D movement as you described). You should not be picking a random point each frame, rather you should be moving a random distance around the perimeter of the circle.
The algorithm typically runs like this
Offset the target position from the current target position by a random amount
Project the target position back onto the circle centred on your vehicle
The output from this function goes into steeringDirection. You could easily pass it back as a return parameter instead.
You probably want to use invoke repeating or some such to provide frame rate independence. Otherwise this function will produce noticeably different behaviour based on the frequency of recalculation of the steeringDirection.