MOD: Enemy AI

MOD: Player Shooting
MOD: Damage Player and Enemy
This commit is contained in:
2024-09-05 20:40:50 +02:00
parent 4d0e81695d
commit 1eeafca3f2
36 changed files with 1072 additions and 508 deletions

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletScript : MonoBehaviour
{
private Vector3 mousePos;
private Camera mainCamera;
private Rigidbody2D rb;
public float force;
public Weapon weapon;
// Start is called before the first frame update
void Start()
{
mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
rb = GetComponent<Rigidbody2D>();
mousePos = mainCamera.ScreenToWorldPoint(Input.mousePosition);
Vector3 direction = mousePos - transform.position;
Vector3 rotation = transform.position - mousePos;
rb.velocity = new Vector2(direction.x, direction.y).normalized * force;
float rot = Mathf.Atan2(rotation.y, rotation.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0, 0, rot + 90);
}
private void OnTriggerEnter2D(Collider2D other) {
Destroy(this.gameObject);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 622784c880831334db51422cb3845e4a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: