Files
GMTKGameJam2020/Assets/Scripts/BulletScript.cs
T

42 lines
807 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletScript : MonoBehaviour
{
2020-07-11 10:51:01 -04:00
private float speed;
private Rigidbody2D rb;
private ShakeScript shake;
void Start()
{
rb = GetComponent<Rigidbody2D>();
2020-07-11 10:51:01 -04:00
speed = Random.Range(3.0f, 8.0f);
shake = GameObject.Find("Shake Manager").GetComponent<ShakeScript>();
shake.CamShake();
}
void FixedUpdate()
{
rb.velocity = transform.up * speed;
}
void OnCollisionEnter2D(Collision2D other)
{
if(other.gameObject.tag != "Player" && other.gameObject.tag != "Bullet")
{
Destroy(gameObject);
}
}
void OnBecameInvisible()
{
Destroy(gameObject);
}
}