using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class moveVillian : MonoBehaviour
{
    // Start is called before the first frame update
    [SerializeField] float raycastX, villMove;
    [SerializeField] Rigidbody2D villianRB2D;
    [SerializeField] LayerMask villsWalls;
    bool OnRotate;
    void Start()
    {

    }

    // Update is called once per frame
    void FixedUpdate()
    {
      Physics2D.gravity = new Vector3(0f, -50f, 0f);
      OnRotate = Physics2D.Raycast(transform.position, transform.right, raycastX, villsWalls);
      villianRB2D.AddForce(transform.rotation * new Vector2(villMove, 0f));
      if(OnRotate == true){
        transform.Rotate(new Vector3(0f, 180f, 0f));
      }
      Debug.Log(OnRotate);

    }

    void OnDrawGizmos(){
      Gizmos.color = Color.red;
      Gizmos.DrawLine(transform.position, transform.position + transform.right * raycastX);
    }
}