How can i reverse the direction my enemy is walking on collision with objects tagged as walls in C#?
Here’s the Move Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveScript : MonoBehaviour
{
public Vector2 speed = new Vector2(10, 10);
public Vector2 direction = new Vector2(-1, 0);
void Update ()
{
Vector3 movement = new Vector3(speed.x * direction.x, speed.y * direction.y, 0);
movement *= Time.deltaTime;
transform.Translate(movement);
}
}