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
- {
- float speed = 10;
- public GameObject player;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- Vector3 rotation = new Vector3(15,30,45) * Time.deltaTime * speed;
- transform.Rotate(rotation);
- Vector3 vector = transform.position - player.transform.position;
- float magnitude = vector.magnitude;
- if (magnitude > 3)
- {
- GetComponent<MeshRenderer>().material.color = Color.red;
- }
- else
- {
- GetComponent<MeshRenderer>().material.color = Color.blue;
- }
- }
- }
Add Comment
Please, Sign In to add comment