FollowHead.cs 490 B

1234567891011121314151617181920212223
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class FollowHead : MonoBehaviour
  5. {
  6. [SerializeField]
  7. GameObject Head;
  8. private MeshRenderer mesh;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. mesh = GetComponent<MeshRenderer>();
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. transform.position = Head.transform.position - Vector3.up * mesh.bounds.size.y/2 ;
  18. }
  19. }