# Wander steering behavior bounce off the wall question

by user3513743   Last Updated January 14, 2018 03:13 AM

Doing some wandering steering behavior. Trying to make it bounce off the wall and not get caught on the wall. I got a Current Position, Velocity, and a little acceleration. These are the two functions that im using for wander steering behavior. Thank you for helping.

//--------------------------- Wander -------------------------------------
//
//  This behavior makes the agent wander about randomly
//------------------------------------------------------------------------
Vector2D SteeringBehavior::Wander()
{
//this behavior is dependent on the update rate, so this line must
//be included when using time independent framerate.
double JitterThisTimeSlice = m_dWanderJitter * m_pVehicle->TimeElapsed();

//first, add a small random vector to the target's position
m_vWanderTarget += Vector2D(RandomClamped() * JitterThisTimeSlice,
RandomClamped() * JitterThisTimeSlice);

//reproject this new vector back on to a unit circle
m_vWanderTarget.Normalize();

//increase the length of the vector to the same as the radius
//of the wander circle

//move the target into a position WanderDist in front of the agent
Vector2D target = m_vWanderTarget + Vector2D(m_dWanderDistance, 0);

//project the target into world space
Vector2D Target = PointToWorldSpace(target,
m_pVehicle->Side(),
m_pVehicle->Pos());

//and steer towards it
return Target - m_pVehicle->Pos();
}

/------------------------------- Seek -----------------------------------
//
//  Given a target, this behavior returns a steering force which will
//  direct the agent towards the target
//------------------------------------------------------------------------
Vector2D SteeringBehavior::Seek(Vector2D TargetPos)
{
Vector2D DesiredVelocity = Vec2DNormalize(TargetPos - m_pVehicle->Pos())
* m_pVehicle->MaxSpeed();

return (DesiredVelocity - m_pVehicle->Velocity());
}
Tags :