Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Bullet : MonoBehaviour {
  6.  
  7. Transform player;
  8. Vector3 pos_player;
  9. public float hit = 20;
  10. public float tempo;
  11.  
  12. void Start () {
  13.  
  14. player = GameObject.FindGameObjectWithTag ("Player").transform;
  15. pos_player = player.position;
  16. }
  17.  
  18. // Update is called once per frame
  19. void Update () {
  20. transform.position = Vector3.MoveTowards (transform.position,pos_player,50 * Time.deltaTime);
  21.  
  22. if(Vector3.Distance (transform.position,player.position) > 20)
  23. {
  24. //Destroy (this.gameObject);
  25. }
  26.  
  27. Destroy (this.gameObject,10f);
  28.  
  29. }
  30.  
  31. void OnTriggerEnter(Collider other)
  32. {
  33. switch(other.tag)
  34. {
  35. case "Player":
  36. Destroy (this.gameObject);
  37. break;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement