Advertisement
Kenkaster001

collectible

Sep 17th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement