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 Cylinder : MonoBehaviour
- {
- public GameObject player;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- Vector3 v = player.transform.position - transform.position;
- float magnitude = v.magnitude;
- transform.LookAt(player.transform.position);
- if (magnitude >= 3)
- {
- transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
- Vector3 n = v.normalized * Time.deltaTime;
- transform.Translate(n);
- }
- else if (magnitude < 3)
- {
- transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement