Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MoveLeft : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8. private float speed = 10.0f;
  9. private PlayerController playerControllerScript;
  10. private float leftBound = -10.0f;
  11. void Start()
  12. {
  13. playerControllerScript = GameObject.Find("Player").GetComponent<PlayerController>();
  14. }
  15.  
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. if(playerControllerScript.gameOver == false)
  20. {
  21. transform.Translate(Vector3.left * Time.deltaTime * speed);
  22. }
  23.  
  24.  
  25.  
  26. if(transform.position.x < leftBound && gameObject.CompareTag("Obstacle") )
  27. {
  28. Destroy(gameObject);
  29. }
  30.  
  31.  
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement