Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Collectible : MonoBehaviour
- {
- Rigidbody rb;
- // Start is called before the first frame update
- void Start()
- {
- rb = GetComponent<Rigidbody>();
- }
- // Update is called once per frame
- void Update()
- {
- float y = 1;
- Vector3 r = new Vector3(0, y, 0);
- rb.AddRelativeTorque(r);
- if (transform.position.y <= 1f)
- {
- //Boracay pic ni Dani
- float x = 1;
- Vector3 v = new Vector3(0, x, 0) * 50;
- rb.AddRelativeForce(v);
- }
- else if (transform.position.y >= 2.5f)
- {
- float x = -1;
- Vector3 v = new Vector3(0, x, 0) * 50;
- rb.AddRelativeForce(v);
- //Frances Realda
- }
- }
- public void OnTriggerEnter(Collider other)
- {
- if (other.name == "Player")
- {
- Destroy(gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement