Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualÁlvaro

Posted 20 November 2012 - 01:15 PM

double speed = distance / ((double)deceleration * decelerationTweaker);
  speed = Math.Min(speed, MaxSpeed);
  Vector2 desiredVelocity = toTarget * speed / distance;
  return desiredVelocity - Velocity;


This is fishy. Notice how speed is proportional to distance, but then it gets divided by distance. This means your desiredVelocity is simply toTarget / some_constant. The resulting dynamics are those of an undamped pendulum, so of course you get oscillatory behavior. I don't have the book in front of me to compare the code, but that can't be what they are doing.

#3Álvaro

Posted 20 November 2012 - 01:15 PM

double speed = distance / ((double)deceleration * decelerationTweaker);
  speed = Math.Min(speed, MaxSpeed);
  Vector2 desiredVelocity = toTarget * speed / distance;
  return desiredVelocity - Velocity;


This is fishy. Notice how speed is proportional to distance, but then it gets divided by distance. This means your desiredVelocity is simply toTarget / some_constant. The resulting dynamics are that of an undamped pendulum, so of course you get oscillatory behavior. I don't have the book in front of me to compare the code, but that can't be what they are doing.

#2Álvaro

Posted 20 November 2012 - 01:15 PM

double speed = distance / ((double)deceleration * decelerationTweaker);
								speed = Math.Min(speed, MaxSpeed);
								Vector2 desiredVelocity = toTarget * speed / distance;
								return desiredVelocity - Velocity;


This is fishy. Notice how speed is proportional to distance, but then it gets divided by distance. This means your desiredVelocity is simply toTarget / some_constant. The resulting dynamics are that of an undamped pendulum, so of course you get oscillatory behavior. I don't have the book in front of me to compare the code, but that can't be what they are doing.

#1Álvaro

Posted 20 November 2012 - 01:14 PM

double speed = distance / ((double)deceleration * decelerationTweaker);
							    speed = Math.Min(speed, MaxSpeed);
							    Vector2 desiredVelocity = toTarget * speed / distance;
							    return desiredVelocity - Velocity;


This is fishy. Notice how speed is proportional to distance, but then the only place that uses speed is dividing it by distance. This means your desiredVelocity is simply toTarget / some_constant. The resulting dynamics are that of an undamped pendulum, so of course you get oscillatory behavior. I don't have the book in front of me to compare the code, but that can't be what they are doing.

PARTNERS