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 MoveLeft : MonoBehaviour
- {
- private float speed = 25;
- private PlayerController playerControllerScript;
- private float leftBound = -15;
- // Start is called before the first frame update
- void Start()
- {
- playerControllerScript = GameObject.Find("Player").GetComponent<PlayerController>();
- }
- // Update is called once per frame
- void Update()
- { //if the player hits ob the gme stops and the things stop moving
- //obs move double speed if player is moving double speed
- if (playerControllerScript.gameOver == false)
- {
- if (playerControllerScript.doubleSpeed)
- {
- transform.Translate(Vector3.left * Time.deltaTime * (speed * 2));
- }
- else
- {
- transform.Translate(Vector3.left * Time.deltaTime * speed);
- }
- }
- // destroys obstacles once they pass out of bounds
- if (transform.position.x < leftBound && gameObject.CompareTag("Obstacle"))
- {
- Destroy(gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement