I'm working on my top-down game. y characters use pathfinding + steering behaviors(Arrive and FollowPath) to move. I've implemented my character class from libgdx SteeringActor class (from tests). So the question, how can I limit the angular speed to make characters not turn around instantly.
private void applySteering(SteeringAcceleration<Vector2> steering,
float time) {
// Update position and linear velocity. Velocity is trimmed to maximum
// speed
position.mulAdd(linearVelocity, time);
setX(position.x);
setY(position.y);
linearVelocity.mulAdd(steering.linear, time).limit(getMaxLinearSpeed());
// Update orientation and angular velocity
if (independentFacing) {
setRotation(getRotation() + (angularVelocity * time)
* MathUtils.radiansToDegrees);
angularVelocity += steering.angular * time;
body.move(position, getRotation());
} else {
// If we haven't got any velocity, then we can do nothing.
if (!linearVelocity.isZero(0.001f)) {
float newOrientation = vectorToAngle(linearVelocity);
angularVelocity = (newOrientation - getRotation()
* MathUtils.degreesToRadians)
* time; // this is superfluous if independentFacing is
// always true
body.move(position, newOrientation);
setRotation(newOrientation * MathUtils.radiansToDegrees);
}
}
}
So there is limiter for linear speed,but no limiter for angular. (IndependentFacing = false;)
body.move()-is function to rotate and move collision representation of character. body is object of my class, I'm not using Box2d.