Advertisement
jemmm

Untitled

Sep 18th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 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. float y = 1;
  18.  
  19. Vector3 r = new Vector3(0, y, 0);
  20.  
  21.  
  22. rb.AddRelativeTorque(r);
  23.  
  24. if (transform.position.y <= 1f)
  25. {
  26. //Boracay pic ni Dani
  27. float x = 1;
  28.  
  29. Vector3 v = new Vector3(0, x, 0) * 50;
  30.  
  31. rb.AddRelativeForce(v);
  32. }
  33. else if (transform.position.y >= 2.5f)
  34. {
  35. float x = -1;
  36.  
  37. Vector3 v = new Vector3(0, x, 0) * 50;
  38.  
  39. rb.AddRelativeForce(v);
  40. //Frances Realda
  41. }
  42. }
  43. public void OnTriggerEnter(Collider other)
  44. {
  45. if (other.name == "Player")
  46. {
  47. Destroy(gameObject);
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement