Created
June 18, 2015 22:58
-
-
Save jbasinger/c7947550cb12e6fb1bec to your computer and use it in GitHub Desktop.
BulletMovement
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 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