Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [RequireComponent(typeof(VisibleOrNot))]
- public class WeepingAngel : MonoBehaviour
- {
- private VisibleOrNot _visibleOrNot;
- private void Awake()
- {
- _visibleOrNot = GetComponent<VisibleOrNot>();
- }
- // Use this for initialization
- private void Start()
- {
- }
- // Update is called once per frame
- private void Update()
- {
- if (!_visibleOrNot.IsVisible)
- {
- Vector3 targetDir = Camera.main.transform.position - transform.position;
- float step = .5f * Time.deltaTime;
- Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0F);
- transform.rotation = Quaternion.LookRotation(newDir);
- transform.position = Vector3.MoveTowards(transform.position, Camera.main.transform.position, .5f * Time.deltaTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement