how to make ai move in unity 2d code example
Example 1: unity movetowards 2d
/// <summary>
/// Move 2D sprite towards target
/// </summary>
/// <param name="target"></param>
/// <param name="movementSpeed"></param>
private void Move(Vector3 target, float movementSpeed)
{
//Move
transform.position += (target - transform.position).normalized * movementSpeed * Time.deltaTime;
}
Example 2: move to where it facing unity 2d
transform.up