Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Platformer/Platformer/Assets/Scripts/Player&Enemy/Bullet.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
64 lines (47 sloc)
1.22 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Bullet : MonoBehaviour | |
{ | |
public float speed = 20f; | |
public Rigidbody2D rb; | |
private static bool facingright; //facing right? reference to playerinput | |
float constantspeed = 20f; | |
int shurikenDamage = 15; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
void Update () | |
{ | |
facingright = PlayerInput.m_FacingRight; | |
if (facingright == true) | |
{ | |
rb.velocity = transform.right * constantspeed; | |
} | |
if (facingright == false ) | |
{ | |
rb.velocity = -transform.right * constantspeed; | |
} | |
} | |
private void OnTriggerEnter2D(Collider2D other) | |
{ | |
if( other.gameObject.CompareTag("Enemy")) | |
{ | |
Destroy(gameObject); | |
} | |
if (other.gameObject.CompareTag("Bee")) | |
{ | |
Destroy(gameObject); | |
SoundManagerScript.PlaySound("BeeHit"); | |
} | |
if (other.gameObject.CompareTag("Wall")) | |
{ | |
Destroy(gameObject); | |
} | |
if (other.gameObject.CompareTag("Box")) | |
{ | |
Destroy(other.gameObject); | |
} | |
} | |
} |