Skip to content
Permalink
e13c256101
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
56 lines (42 sloc) 1.07 KB
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("Wall"))
{
Destroy(gameObject);
}
if (other.gameObject.CompareTag("Box"))
{
Destroy(other.gameObject);
}
}
}