Mount.cs 618 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. public class Mount : MonoBehaviour
  3. {
  4. public GameObject mountPoint;
  5. // Start is called once before the first execution of Update after the MonoBehaviour is created
  6. void Start()
  7. {
  8. if (mountPoint != null)
  9. {
  10. var rb = transform.parent.GetComponent<Rigidbody>();
  11. var diff = transform.position - mountPoint.transform.position;
  12. mountPoint.transform.parent.position += diff;
  13. mountPoint.transform.parent.rotation = transform.rotation;
  14. }
  15. }
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. }
  20. }