33 lines
798 B
C#
33 lines
798 B
C#
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<Rigidbody2D>();
|
|
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()
|
|
{
|
|
|
|
}
|
|
}
|