Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class skrypt : MonoBehaviour
  6. {
  7. public Transform p1;
  8. public Transform p2;
  9. public Transform p3;
  10.  
  11. void Start ()
  12. {
  13. GameObject obj = new GameObject();
  14. obj.name = "Collider";
  15. obj.AddComponent<BoxCollider>();
  16. BoxCollider col = obj.GetComponent<BoxCollider>();
  17.  
  18. Vector3 pos = (p1.position + p2.position) / 2;
  19. pos.y += 20;
  20. obj.transform.position = pos;
  21.  
  22. float y = pos.y;
  23. var pos1 = new Vector3(p1.position.x, y, p1.position.z);
  24. var pos2 = new Vector3(p2.position.x, y, p2.position.z);
  25. var pos3 = new Vector3(p3.position.x, y, p3.position.z);
  26. col.size = new Vector3(Vector3.Distance(pos1, pos3), 60, Vector3.Distance(pos2, pos3));
  27.  
  28. Vector3 center = Vector3.Lerp(pos1, pos3, 0.5f);
  29. obj.transform.LookAt(center);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement