# I want to substract a speific ditance from a vector

I want the enemy to stop moving towards the player by a specific distance , I wrote this code:

``````public void InBattle()
{
if(Vector3.Distance (transform.position, target.transform.position) < 10)// if player distance < 10 m;
{
transform.rotation = Quaternion.Slerp (transform.rotation,Quaternion.LookRotation (target.transform.position - transform.position),
rotationSpeed ); // enemy rotates towards the player
transform.position += transform.forward * Time.deltaTime * moveSpeed 	;//enemy moves towards player position
``````

I want the equation to be like this:

``````transform.position += transform.forward * Time.deltaTime * moveSpeed - followDistance	;
``````

where the followDistance is the distance between the player and the enemy let`s say its value of 3

public void InBattle()
{
float followDistance = 3f; // example value
float distance = Vector3.Distance (transform.position, target.transform.position);
if(distance < 10)// if player distance < 10 m;
{
transform.rotation = Quaternion.Slerp (transform.rotation,Quaternion.LookRotation (target.transform.position - transform.position),
rotationSpeed ); // enemy rotates towards the player
if (distance > followDistance) {