SHARE
TWEET

collectible

Kenkaster001 Sep 17th, 2019 88 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.  
  5. public class Collectible : MonoBehaviour
  6. {
  7.     Rigidbody rb;
  8.     // Start is called before the first frame update
  9.     void Start()
  10.     {
  11.         rb = GetComponent<Rigidbody>();
  12.     }
  13.  
  14.     // Update is called once per frame
  15.     void Update()
  16.     {
  17.        
  18.     }
  19.  
  20.     private void FixedUpdate()
  21.     {
  22.         Vector3 r = new Vector3(0,1,0) * 200;
  23.         rb.AddTorque(r);
  24.     }
  25.  
  26.     private void OnTriggerEnter(Collider other)
  27.     {
  28.         if(other.name == "Player")
  29.         {
  30.             other.GetComponent<Player>().score += 1;
  31.             Destroy(gameObject);
  32.         }
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top