Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public class Enemy_Move : MonoBehaviour
  2. {
  3. public GameObject enemy;
  4. public GameObject Sınır1;
  5. public GameObject Sınır2;
  6. public float enemy_hiz = 0.1f;
  7. bool goRight = true;
  8. void Start() {
  9.  
  10.  
  11. }
  12. void Update()
  13. {
  14.  
  15. if (goRight)
  16. {
  17.  
  18. enemy.transform.position = new Vector3(enemy.transform.position.x + enemy_hiz, transform.position.y);
  19. }
  20. else
  21.  
  22. {
  23. enemy.transform.position = new Vector3(enemy.transform.position.x - enemy_hiz, transform.position.y);
  24.  
  25. }
  26.  
  27. float sınır1 = Sınır1.transform.position.x;
  28. float sınır2 = Sınır2.transform.position.x;
  29.  
  30.  
  31. if (enemy.transform.position.x < sınır1) {
  32.  
  33. goRight = true;
  34. }
  35. if (enemy.transform.position.x > sınır2) {
  36. goRight = false;
  37. Debug.Log(enemy.transform.position.x - enemy_hiz);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement