using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyBulletScript : MonoBehaviour { public GameObject player; public Rigidbody2D rb; public float force; public float rotation; public GameObject[] bullets; void Start() { rb = GetComponent(); player = GameObject.FindGameObjectWithTag("Player"); Vector3 direction = player.transform.position - transform.position; rb.velocity = new Vector2(direction.x, direction.y).normalized * force; float rot = Mathf.Atan2(-direction.y, -direction.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.Euler(0,0, rot + rotation); } // Update is called once per frame void Update() { } }