Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public float speed;
  4.  
  5. public Player player;
  6.  
  7.  
  8.  
  9. // Use this for initialization
  10. void Start () {
  11.  
  12.  
  13. }
  14.  
  15. // Update is called once per frame
  16. void Update () {
  17.  
  18. GetComponent<Rigidbody2D>().velocity = new Vector2(speed, GetComponent<Rigidbody2D>().velocity.y);
  19.  
  20.  
  21.  
  22. }
  23.  
  24. void OnTriggerEnter2D(Collider2D other)
  25.  
  26. {
  27.  
  28. Destroy (gameObject);
  29.  
  30. }
  31.  
  32. using UnityEngine;
  33.  
  34. public float speed;
  35.  
  36. public Player player;
  37. private bool _facingRight = true;
  38.  
  39.  
  40. // Use this for initialization
  41. void Start()
  42. {
  43.  
  44. //Finds the object called Player, which is the main controller for the protagonist
  45. player = FindObjectOfType<Player>();
  46.  
  47.  
  48. //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
  49.  
  50. }
  51.  
  52.  
  53. // Update is called once per frame
  54. void Update()
  55. {
  56. GetComponent<Rigidbody2D>().velocity = new Vector2(speed, GetComponent<Rigidbody2D>().velocity.y);
  57. }
  58.  
  59. void OnTriggerEnter2D(Collider2D other)
  60. {
  61.  
  62. Destroy(gameObject);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement