Opponent moving back and forth

What I want

Why I want it

Additional information (optional)

Similar approaches can be used as in the “How do I…” tutorial “add moving platforms”. Here are the options:

  1. Using a timer and a relative orientation.
  2. Using a timer and a variable, to avoid changing the orientation.

In addition, for an opponent, another simple approach is the following:

  • Always apply a relative force towards a direction.
  • When in contact with a background marker object of a given type, stop and switch orientation. Then maybe add a little movement to restart directly.

If the opponent has zero friction with the ground (like it is on ice), it is possible to not add the force, but instead just add the movement initially and upon contact with the marker object.

If my explanation is not clear, I can also provide a small demo game.