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 skrypt : MonoBehaviour
- {
- public Transform p1;
- public Transform p2;
- public Transform p3;
- void Start ()
- {
- GameObject obj = new GameObject();
- obj.name = "Collider";
- obj.AddComponent<BoxCollider>();
- BoxCollider col = obj.GetComponent<BoxCollider>();
- Vector3 pos = (p1.position + p2.position) / 2;
- pos.y += 20;
- obj.transform.position = pos;
- float y = pos.y;
- var pos1 = new Vector3(p1.position.x, y, p1.position.z);
- var pos2 = new Vector3(p2.position.x, y, p2.position.z);
- var pos3 = new Vector3(p3.position.x, y, p3.position.z);
- col.size = new Vector3(Vector3.Distance(pos1, pos3), 60, Vector3.Distance(pos2, pos3));
- Vector3 center = Vector3.Lerp(pos1, pos3, 0.5f);
- obj.transform.LookAt(center);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement