Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class Coin : MonoBehaviour
- {
- public float jumpForce = 5;
- void OnTriggerEnter(Collider other)
- {
- if (other.gameObject.tag == "Sonic")
- {
- other.GetComponent<Rigidbody>().AddForce(new Vector3(0, jumpForce, 0)); // Add force to player with amount of jumpForce
- other.GetComponent<Player>().canJump = true;
- ScoreManager.SCORE += 10;
- Destroy(gameObject);
- }
- if (other.gameObject.tag == "Ground")
- {
- Destroy(gameObject);
- Debug.Log("Trigger entered");
- }
- }
- void OnCollisionEnter(Collision col)
- {
- if (col.gameObject.tag == "Ground")
- {
- ScoreManager.SCORE = 0;
- SceneManager.LoadScene(2);
- Cursor.lockState = CursorLockMode.None;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement