Last active
January 15, 2021 10:14
-
-
Save AmmarTee/e4ffdc213f2faf6a1f7d5179d59378eb to your computer and use it in GitHub Desktop.
Our Bootcamp Scripts for Students
This file contains hidden or 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
using UnityEngine; | |
public class cameraFollow : MonoBehaviour | |
{ | |
public GameObject player; | |
public float offset; | |
// Update is called once per frame | |
void Update() | |
{ | |
gameObject.transform.position = new Vector3(player.transform.position.x , gameObject.transform.position.y , player.transform.position.z + offset); | |
} | |
} |
This file contains hidden or 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
using UnityEngine.UI; | |
public class coll : MonoBehaviour | |
{ | |
public static bool isFinished; | |
public Text finish_lable; | |
private void OnTriggerEnter(Collider other) | |
{ | |
if (other.CompareTag("Obs")){ | |
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); | |
} | |
if (other.CompareTag("Fns")) | |
{ | |
isFinished = true; | |
Time.timeScale = 0; | |
finish_lable.text = "Congratulations"; | |
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); | |
} | |
} | |
private void Start() | |
{ | |
isFinished = false; | |
Time.timeScale = 1; | |
} | |
private void Update() | |
{ | |
if (gameObject.transform.position.y < -10) | |
{ | |
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); | |
} | |
} | |
} |
This file contains hidden or 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class forcingObject : MonoBehaviour | |
{ | |
public Rigidbody rb; | |
void Start() | |
{ | |
rb.useGravity = true; | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
} | |
} |
This file contains hidden or 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class movement : MonoBehaviour | |
{ | |
private Rigidbody rb; | |
public float speed; | |
void Start() | |
{ | |
rb = gameObject.GetComponent<Rigidbody>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
// movementForce(); | |
if (!coll.isFinished) | |
{ | |
movementTranslate(); | |
} | |
} | |
private void movementTranslate() | |
{ | |
if (Input.GetKey(KeyCode.W)) | |
{ | |
gameObject.transform.Translate(new Vector3(0, 0, 1*speed),Space.World); | |
} | |
if (Input.GetKey(KeyCode.S)) | |
{ | |
gameObject.transform.Translate(new Vector3(0, 0, -1*speed), Space.World); | |
} | |
if (Input.GetKey(KeyCode.A)) | |
{ | |
gameObject.transform.Translate(new Vector3(-1*speed, 0, 0), Space.World); | |
} | |
if (Input.GetKey(KeyCode.D)) | |
{ | |
gameObject.transform.Translate(new Vector3(1*speed, 0, 0), Space.World); | |
} | |
} | |
private void movementForce() | |
{ | |
if (Input.GetKey(KeyCode.W)) | |
{ | |
rb.AddForce(0, 0, 1 * speed, ForceMode.VelocityChange); | |
} | |
if (Input.GetKey(KeyCode.S)) | |
{ | |
rb.AddForce(0, 0, -1 * speed, ForceMode.VelocityChange); | |
} | |
if (Input.GetKey(KeyCode.A)) | |
{ | |
rb.AddForce(-1 * speed, 0, 0, ForceMode.VelocityChange); | |
} | |
if (Input.GetKey(KeyCode.D)) | |
{ | |
rb.AddForce(1 * speed, 0, 0, ForceMode.VelocityChange); | |
} | |
} | |
} |
This file contains hidden or 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
using UnityEngine; | |
using UnityEngine.UI; | |
public class score : MonoBehaviour | |
{ | |
public Text score_Lable; | |
// Update is called once per frame | |
void Update() | |
{ | |
int scoreInt = (int)gameObject.transform.position.z; | |
score_Lable.text = scoreInt.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment