Why is ForceMode2D.Impulse working continuously and not suddenly?

Essentially what I’m trying to do is make the enemy "roll’ towards the player quickly when it sees it. The raycast is working and it can see the player, but when the force it added its not a quick impulse of force, its a continuous movement. I’ve tried everything to make this work. Originally I had it in the update function and set “canAtc”(can attack) to false after adding the force, but it was still continuous. I then tried to stop the patrol sequence before adding the force (the patrol sequence is just walking back and forth, then pausing, and repeating) but that didn’t help. I then tried it in fixed update, and then tried to invoke it in fixed update, thinking that in its own method there’s no way it can repeat. That didn’t help.
I’m relatively new to coding and might just have some syntax error or easy fix, so any help is appreciated. Thanks :slight_smile:

public class Enemy1Roll : MonoBehaviour
{
public float speed = 2;
public float timeTurn = 2;
public float sightDist;
public Vector2 rollAmnt = new Vector2(5, 0);
private bool moveRight = true;
private bool chill = true;
private bool canSee = false;
private bool canAtc = true;
private bool patrol = true;
public GameObject Player;
public Transform visionCaster;
private Rigidbody2D rb;
private Animator anim;
[SerializeField] private LayerMask layerMask;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    anim = GetComponent<Animator>();

    InvokeRepeating("Patrol", 0, 2);
    InvokeRepeating("Chill", 0, 5);
}

void Patrol()
{
    moveRight = !moveRight;
}

void Chill()
{
    chill = !chill;
}

void Update()
{
    RaycastHit2D raycastHit2D = Physics2D.Raycast(visionCaster.position, transform.TransformDirection(Vector2.left), 7, layerMask);

    if (patrol)
    {
        if (raycastHit2D.collider != null)
        {
            Debug.DrawRay(visionCaster.position, transform.TransformDirection(Vector2.left) * 7, Color.yellow);
            canSee = true;
        }

        else
        {
            Debug.DrawRay(visionCaster.position, transform.TransformDirection(Vector2.left) * 7, Color.white);
            canSee = false;
        }

        if (moveRight && !chill)
        {
            anim.SetBool("Walking", true);
            transform.eulerAngles = new Vector3(0, -180, 0);
            transform.Translate(Vector2.left * speed * Time.deltaTime);
        }

        else if (!chill)
        {
            anim.SetBool("Walking", true);
            transform.eulerAngles = new Vector3(0, 0, 0);
            transform.Translate(Vector2.left * speed * Time.deltaTime);
        }

        else if (chill)
        {
            anim.SetBool("Walking", false);
        }
    }
  
}

void FixedUpdate()
{
    if (canSee && canAtc)
    {
        patrol = false;
        Roll();
        canAtc = false;
    }
}

void Roll()
{
    rb.AddForce(Vector2.left * 5f, ForceMode2D.Impulse);
}

}

Try replacing your FixedUpdate with this:

void FixedUpdate()
{
    if (canSee == true && canAtc == true)
    {
         patrol = false;
         Roll();
         canAtc = false;
    }
}