Files
ClearTheZone/Assets/Scripts/Bullet.cs
T
PBA3H25ABU 0b1a359bd9 Revert "fix1.2"
This reverts commit c35a879034.
2026-08-20 11:38:34 +02:00

45 lines
1.0 KiB
C#

//Oliver
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float speed;
public int damage;
private Vector3 position = Vector3.forward;
private Rigidbody rb;
void Start()
{
GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
transform.Translate(position.normalized * speed * Time.deltaTime);
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Enemy")
{
<<<<<<< HEAD
Destroy(collision.gameObject);
=======
EnemyHealth enemy = collision.gameObject.GetComponent<EnemyHealth>();
if (enemy != null)
{
enemy.TakeDamage(damage);
Destroy(gameObject);
}
>>>>>>> parent of 392d236 (Merge branch 'main' of https://git.bib.de/PBA3H25ABU/ClearTheZone)
}
else if(collision.gameObject.tag == "Wall")
{
Destroy(this);
}
}
}