Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEditor;
- using UnityEngine;
- public class BulletController : MonoBehaviour
- {
- public PlayerController player;
- public float bulletSpeed;
- public GameObject enemyDeathPartical;
- public GameObject bulletImpactPartical;
- public int pointsForKillingEnemy;
- public float rotationSpeed;
- public int bulletDamage;
- //private Rigidbody2D myRigidBody2D;//
- // Start is called before the first frame update
- void Start()
- {
- player = FindAnyObjectByType<PlayerController>();
- if (player.transform.localScale.x < 0)
- {
- bulletSpeed = -bulletSpeed;
- rotationSpeed = -rotationSpeed;
- }
- }
- // Update is called once per frame
- void Update()
- {
- GetComponent<Rigidbody2D>().velocity = new Vector2(bulletSpeed, GetComponent<Rigidbody2D>().velocity.y);
- GetComponent<Rigidbody2D>().angularVelocity = rotationSpeed; // Make the bullet rotate if needed
- }
- void OnTriggerEnter2D(Collider2D other)
- {
- if (other.tag == "Enemy")
- {
- //Instantiate(enemyDeathPartical, other.transform.position, other.transform.rotation);
- //Destroy(other.gameObject);
- // ScoreManager.AddPoints(pointsForKillingEnemy);
- other.GetComponent<EnemyHealthManager>().giveDamage(1);
- }
- if (other.tag == "Boss")
- {
- //Instantiate(enemyDeathPartical, other.transform.position, other.transform.rotation);
- //Destroy(other.gameObject);
- // ScoreManager.AddPoints(pointsForKillingEnemy);
- other.GetComponent<BossHealthManager>().giveDamage(1);
- }
- Instantiate(bulletImpactPartical, transform.position, transform.rotation);
- Destroy (gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement