Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyBehavior : MonoBehaviour {
- float timer;
- public float time;
- Vector3 one = new Vector3(-8.5f, 3, 0);
- Vector3 two = new Vector3(-8.5f, -0.3f, 0);
- Vector3 three = new Vector3(-8.5f, -3.3f, 0);
- int lane = 0;
- public Transform fly;
- void Timer()
- {
- timer -= Time.deltaTime;
- if (timer <= 0.0f)
- {
- /*if (gameObject.tag == "flying")
- {
- findLane();
- int r = Random.Range(1, 3);
- if(lane == 1 && r == 1 || lane == 3 && r == 1)
- {
- gameObject.transform.position = two;
- }
- else if(lane == 1 && r == 2 || lane == 2 && r == 2)
- {
- gameObject.transform.position = three;
- }
- else if (lane == 2 && r == 1 || lane == 3 && r == 1)
- {
- gameObject.transform.position = one;
- }
- }*/
- Destroy(this.gameObject);
- timer = time;
- }
- }
- void findLane()
- {
- if (transform.position.y == 3)
- {
- lane += 1;
- }
- else if (transform.position.y == -0.3f)
- {
- lane += 2;
- }
- else if (transform.position.y == -3.3f)
- {
- lane += 3;
- }
- }
- // Use this for initialization
- void Start () {
- timer = time;
- }
- void move()
- {
- transform.Translate(-0.08f, 0, 0);
- }
- // Update is called once per frame
- void Update () {
- move();
- Timer();
- Debug.Log(lane.ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement