-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathBallAuthoring.cs
37 lines (32 loc) · 974 Bytes
/
BallAuthoring.cs
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
using Tutorials.Kickball.Step2;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
namespace Tutorials.Kickball.Step3
{
public class BallAuthoring : MonoBehaviour
{
class Baker : Baker<BallAuthoring>
{
public override void Bake(BallAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.Dynamic);
// A single authoring component can add multiple components to the entity.
AddComponent<Ball>(entity);
AddComponent<Velocity>(entity);
// Used in Step 5
AddComponent<Carry>(entity);
SetComponentEnabled<Carry>(entity, false);
}
}
}
// A tag component for ball entities.
public struct Ball : IComponentData
{
}
// A 2d velocity vector for the ball entities.
public struct Velocity : IComponentData
{
public float2 Value;
}
}