Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public float speed;
- public Player player;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- GetComponent<Rigidbody2D>().velocity = new Vector2(speed, GetComponent<Rigidbody2D>().velocity.y);
- }
- void OnTriggerEnter2D(Collider2D other)
- {
- Destroy (gameObject);
- }
- using UnityEngine;
- public float speed;
- public Player player;
- private bool _facingRight = true;
- // Use this for initialization
- void Start()
- {
- //Finds the object called Player, which is the main controller for the protagonist
- player = FindObjectOfType<Player>();
- //If the player decides to face left, the speed of the "Fireball" is going to become negative, because it is aimed to the oposite direction from the normal position
- }
- // Update is called once per frame
- void Update()
- {
- GetComponent<Rigidbody2D>().velocity = new Vector2(speed, GetComponent<Rigidbody2D>().velocity.y);
- }
- void OnTriggerEnter2D(Collider2D other)
- {
- Destroy(gameObject);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement