This topic is 3337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys, I am implementing the simple vehicle model (2D) described in Craig Reynold's Steering Behaviors, like this: for each frame: steeringForce.truncate(maxForce); acceleration=steeringForce/mass; velocity+=acceleration*timespan; velocity.truncate(maxSpeed); position+=velocity*timespan; How can I add a turning radius to this model, so that if it's going North and wants to go South it has to do a loop instead of coming to a stop and then speeding up in the opposite direction ? Thank you.

##### Share on other sites
I dont understand your steeringForce variable. It seems to be more of a "total force." I also see no mention of angular position or angular velocity. You're going to need both of these to do what you ask.

Your steering force should generate a torque and therefor angular acceleration. When your angular velocity is non zero the car will be turning. You can determine the angular velocity from the desired turning radius and tangential velocity. Integrate this angular velocity until the car is facing in the desired direction.

##### Share on other sites
Quote:
 I dont understand your steeringForce variable. It seems to be more of a "total force."
For what it's worth, what Endemoniada posted is the usual method of applying the computed force for steering behaviors (or at least it's the general idea - I didn't check the code too carefully).

A 'canonical' implementation of steering behaviors typically treats the agents as particles and ignores angular effects. The orientation of the agents is typically computed via other means (for example, it's fairly common simply to align the agent with its velocity vector).

That doesn't address the original question, of course (and it may very well be that incorporating a turning radius will require a different approach).

##### Share on other sites
Ah i see.. i was kind of thinking that because really there aren't too many steering behaviors for a car :)

So this is kind of a flocking/AI thing.

I would keep two velocities. One which you integrate your steering force to directly, this is your target velocity. The other velocity will lag slightly behind the target velocity but will have other restrictions such as a maximum direction change per second. You'll constantly be turning the following velocity to match the target velocity. If the target velocity changes signs exactly then you may need to introduce a nudge factor since the following velocity wont know which way to turn.

It's the same issue a 3rd person game has, where the target velocity is directly controlled by the control pad stick, and the following velocity is restricted by animation.

But if this is for a vehicle, i would totally drop this representation. You can still use the steering algorithms to control the trajectory of the vehicle. But your vehicle model needs a serious upgrade.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633709
• Total Posts
3013481
×