forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompoundDemo.cs
More file actions
61 lines (54 loc) · 2.21 KB
/
Copy pathCompoundDemo.cs
File metadata and controls
61 lines (54 loc) · 2.21 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
public class CompoundDemo : BasePhysicsDemo
{
protected unsafe override void Start()
{
//float3 gravity = new float3(0, -9.81f, 0);
float3 gravity = float3.zero;
base.init(gravity);
// // Floor
// {
// BlobAssetReference<Unity.Physics.Collider> collider = Unity.Physics.BoxCollider.Create(new float3(0, -0.1f, 0), Quaternion.identity, new float3(10.0f, 0.1f, 10.0f), 0.05f);
// CreateStaticBody(float3.zero, quaternion.identity, collider);
// }
// Dynamic compound
{
var box = new BoxGeometry
{
Center = float3.zero,
Orientation = quaternion.identity,
Size = new float3(1),
BevelRadius = 0.05f
};
var sphere = new SphereGeometry
{
Center = float3.zero,
Radius = 0.5f
};
var children = new NativeArray<CompoundCollider.ColliderBlobInstance>(3, Allocator.Temp)
{
[0] = new CompoundCollider.ColliderBlobInstance
{
CompoundFromChild = new RigidTransform(quaternion.identity, new float3(-1, 0, 0)),
Collider = Unity.Physics.BoxCollider.Create(box)
},
[1] = new CompoundCollider.ColliderBlobInstance
{
CompoundFromChild = RigidTransform.identity,
Collider = Unity.Physics.SphereCollider.Create(sphere)
},
[2] = new CompoundCollider.ColliderBlobInstance
{
CompoundFromChild = new RigidTransform(quaternion.identity, new float3(1, 0, 0)),
Collider = Unity.Physics.BoxCollider.Create(box)
}
};
BlobAssetReference<Unity.Physics.Collider> collider = CompoundCollider.Create(children);
children.Dispose();
CreateDynamicBody(new float3(0, 1, 0), quaternion.identity, collider, float3.zero, float3.zero, 1.0f);
}
}
}