I am an absolute beginner to coding and need some help with enemy movement. I am attempting to move the enemy from one transform position infinitely but this script I made only enables the movement to the first coordinate.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyCowMovement : MonoBehaviour {
public Rigidbody2D rb;
public float moveforce = 11f;
public float positionPoint = 20f;
// Use this for initialization
void Start () {
if (transform.position.x > 12f)
{
rb.velocity = Vector2.right * moveforce;
}
if (transform.position.x > positionPoint) {
rb.velocity = Vector2.left * moveforce;
}
}