Skip to content

Instantly share code, notes, and snippets.

@jbasinger
Created June 18, 2015 22:58
Show Gist options
  • Save jbasinger/c7947550cb12e6fb1bec to your computer and use it in GitHub Desktop.
Save jbasinger/c7947550cb12e6fb1bec to your computer and use it in GitHub Desktop.
BulletMovement
using UnityEngine;
using System.Collections;
public class BulletMovement : MonoBehaviour {
public float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float magnitude = speed * Time.deltaTime;
this.transform.position = new Vector2(this.transform.position.x,
this.transform.position.y + magnitude);
//Camera.main.ScreenToWorldPoint(
//new Vector3(Camera.main.pixelWidth,0)).x
float topOfTheScreen = Camera.main.ScreenToWorldPoint(
new Vector3(0,Camera.main.pixelHeight)).y;
if(this.transform.position.y > topOfTheScreen){
Destroy(this.gameObject);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment