# Speed dependent arc question

I'm currenlty working on an assignment and would appreciate any sort of help on the following implementation

The question follows

We are tasked to implement some heuristics but one of them is really confusing to me.

The following are a set of heuristics widely used by game developers for the movement of human characters while trying to reach a target

## A. If the character is stationary or moving very slowly

1. If it is a very small distance from its target, it will step there directly, even if this involves moving backward or sidestepping
2. Else if the target is farther away, the character will first turn on the spot to face its target and then move forward to reach it.

## B. Else if the character is moving with some speed

1. If the target is within a speed-dependent arc (like a narrow perception zone, or a cone of perception) in front of it, then it will continue to move forward but add a rotational component to incrementally turn toward the target**

2. Else if the target is outside its arc, then it will stop moving and change direction on the spot before setting off once more.

B2 I'm not entirely sure what a speed dependent arc is. I googled it and it bring it back to the textbook( Artificial Intelligence for video games). My question is : what is a speed dependent arc?

• Pretty sure that's something that is defined in your own assignment context. And it should mean something like how much it character can rotate safely. Like when driving a car, you can easily rotate it as much is you want, but when you are driving at 90mph, making a hard turn will most likely result in a crash! – Ali1S232 Feb 5 '15 at 0:24
• Thanks for the reply Ali, but unfortunately it isn't defined in the assignment. The requirements are taken directly from the textbook which does not define it as well. (books.google.ca/…) – fryBender Feb 5 '15 at 0:40
• So I'll guess it's something that you should define yourself, so that it looks like real life? In fact the book continued to say, it's just as big you can get, without your animation look unnatural. – Ali1S232 Feb 5 '15 at 0:53
• Fair enough. Thanks for you input. I won't mark this as resolved yet, I'm curious to see how the community will respond. – fryBender Feb 5 '15 at 0:59

Hmm, a speed-dependent arc (like a narrow perception zone, or a cone of perception) , you say?

The text book pretty much has made up this term, it is not a standard term as far as I know.

What comes to mind is the following image...

"Speed-Dependent" brings up the idea that the 'cone' changes in size based on (aka 'dependent on') the current speed. For instance, the faster that you are going, the less 'amount' you can turn (and as per B2, if your target is not within this cones angle, then you need to stop the car, and turn slowly in the right direction.

In pseudo code, I think this is pretty much asking the following:

if(currentSpeed<slow){
if(currentSpeed<distanceToTarget){
moveCar(distanceToTarget);
}else{
turnCar(towardsTarget);
moveCar(currentSpeed);
}
}else{
currentSpeedZone = maxTurningZone - (currentSpeed/maxSpeedOfCar*maxTurningZone);//or if you want to make 'speed lanes' (aka: <25=X turning angle, <50=Y turning angle, etc...) you can easily do that instead of generating a 'speedzone'
if(angleToTarget<currentSpeedZone){
moveCar(currentSpeed);
turnCar(towardsTarget);
}else{
stopCar();
turnCar(towardsTarget);
}
}


I personally would add a lot of nuances with slowing down the car (if you are not just using unity's physics for instance), but that is the gist of what they are asking. Hope that helps!

• Damn these non standardized terms! I wish I could upvote you but I still don't have the required rep. Without a shadow of a doubt, yes. It helps! – fryBender Feb 5 '15 at 1:20

'Speed dependent arc' is not a common term and has no specific meaning in game design. The textbook refers to cases where the character is already moving, but not necessarily directly towards the target. If the target is behind you, you would stop, turn around, and start moving again, but if you were moving in roughly the right direction before, you would not stop to do a small rotation. You would instead make the turn on the move.

To decide whether to go for option B1 or B2, you need to define the region in which the target is allowed to be for your current movement direction to be considered 'good enough'. The size and shape of this region (or 'arc', as the textbook incorrectly calls this) may or may not vary with your speed, hence 'speed dependent arc'.