Guest User

Untitled

a guest
Feb 23rd, 2019
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class Coin : MonoBehaviour
  7. {
  8.  
  9.  
  10.  
  11. public float jumpForce = 5;
  12.  
  13. void OnTriggerEnter(Collider other)
  14. {
  15. if (other.gameObject.tag == "Sonic")
  16. {
  17.  
  18. other.GetComponent<Rigidbody>().AddForce(new Vector3(0, jumpForce, 0)); // Add force to player with amount of jumpForce
  19.  
  20. other.GetComponent<Player>().canJump = true;
  21. ScoreManager.SCORE += 10;
  22. Destroy(gameObject);
  23. }
  24. if (other.gameObject.tag == "Ground")
  25. {
  26. Destroy(gameObject);
  27. Debug.Log("Trigger entered");
  28. }
  29.  
  30.  
  31. }
  32.  
  33.  
  34. void OnCollisionEnter(Collision col)
  35. {
  36. if (col.gameObject.tag == "Ground")
  37. {
  38. ScoreManager.SCORE = 0;
  39. SceneManager.LoadScene(2);
  40. Cursor.lockState = CursorLockMode.None;
  41. }
  42. }
  43. }
RAW Paste Data