Created
January 20, 2017 20:02
-
-
Save uruskan/fcef4fa6862fdec509e90c932eee9523 to your computer and use it in GitHub Desktop.
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
public class Enemy_Move : MonoBehaviour | |
{ | |
public GameObject enemy; | |
public GameObject Sınır1; | |
public GameObject Sınır2; | |
public float enemy_hiz = 0.1f; | |
bool goRight = true; | |
void Start() { | |
} | |
void Update() | |
{ | |
if (goRight) | |
{ | |
enemy.transform.position = new Vector3(enemy.transform.position.x + enemy_hiz, transform.position.y); | |
} | |
else | |
{ | |
enemy.transform.position = new Vector3(enemy.transform.position.x - enemy_hiz, transform.position.y); | |
} | |
float sınır1 = Sınır1.transform.position.x; | |
float sınır2 = Sınır2.transform.position.x; | |
if (enemy.transform.position.x < sınır1) { | |
goRight = true; | |
} | |
if (enemy.transform.position.x > sınır2) { | |
goRight = false; | |
Debug.Log(enemy.transform.position.x - enemy_hiz); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment