-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreatePlaneHit.cs
More file actions
46 lines (36 loc) · 1.15 KB
/
CreatePlaneHit.cs
File metadata and controls
46 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreatePlaneHit : MonoBehaviour
{
public Transform A;
public Transform B;
public Transform C;
public Transform D;
public Transform E;
Plane plane;
Line L1;
void Start()
{
plane = new Plane(new Coords(A.position), new Coords(B.position), new Coords(C.position));
L1 = new Line(new Coords(D.position), new Coords(E.position) , Line.LINETYPE.RAY);
L1.Draw(1, Color.green);
for (float s = 0;s <= 1;s += 0.1f)
{
for(float t = 0; t<= 1; t+= 0.1f)
{
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = plane.Lerp(s,t).ToVector();
}
}
float interceptT = L1.IntersectsAt(plane);
if(interceptT == interceptT)
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = L1.Lerp(interceptT).ToVector();
}
}
void Update()
{
}
}