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

  //increase the length of the vector to the same as the radius
  //of the wander circle
  m_vWanderTarget *= m_dWanderRadius;

  //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,

  //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());

Related Questions

Simple wander steering behavior question

Updated January 04, 2018 20:13 PM

Making a wandering object turnaround when hitting wall

Updated January 13, 2018 09:13 AM

Wander steering Behaviour jittering

Updated May 03, 2017 21:13 PM

Wall avoidance steering

Updated February 27, 2017 14:13 PM

Steering Behavior Seeking

Updated June 23, 2017 05:13 AM