60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
|
|
public class WaveBulletScript : MonoBehaviour
|
|
{
|
|
[SerializeField] private float speed = 6f;
|
|
|
|
[SerializeField] private float BulletLiveTime = 3;
|
|
[SerializeField] private float BulletLive = 0;
|
|
|
|
public Vector3 direction = Vector3.up;
|
|
public GameObject WaveBullet;
|
|
public Transform firePoint;
|
|
public Rigidbody2D rb;
|
|
AudioManager audioManager;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Shoot();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
BulletLive += Time.deltaTime;
|
|
if (BulletLive >= BulletLiveTime)
|
|
{
|
|
Destroy(WaveBullet);
|
|
Debug.Log("Unfall");
|
|
BulletLive = 0;
|
|
}
|
|
}
|
|
void Shoot()
|
|
{
|
|
rb.velocity = transform.up * speed;
|
|
//* Time.deltaTime;
|
|
Debug.Log("Bullet bewegt sich");
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D kaputt)
|
|
{
|
|
Debug.Log(kaputt.name);
|
|
|
|
Netz_1Script Netz = kaputt.GetComponent<Netz_1Script>();
|
|
if (Netz != null)
|
|
{
|
|
Netz.TakeDamage();
|
|
}
|
|
Destroy(WaveBullet);
|
|
audioManager.PlaySFX(audioManager.Wave);
|
|
|
|
}
|
|
private void Awake()
|
|
{
|
|
audioManager = GameObject.FindGameObjectWithTag("Audio").GetComponent<AudioManager>();
|
|
}
|
|
}
|