forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCubeRotationSystem.cs
More file actions
33 lines (29 loc) · 852 Bytes
/
Copy pathCubeRotationSystem.cs
File metadata and controls
33 lines (29 loc) · 852 Bytes
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
using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
using Unity.Transforms;
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
public partial class CubeSystem : SystemBase
{
protected override void OnCreate()
{
RequireForUpdate<NetworkStreamInGame>();
}
[WithAll(typeof(CubeTagComponent))]
partial struct CubeJob : IJobEntity
{
public float deltaTime;
public void Execute(Entity entity, ref LocalTransform transform)
{
transform.Rotation = math.mul(transform.Rotation, quaternion.RotateZ(math.radians(100 * deltaTime)));
}
}
protected override void OnUpdate()
{
float deltaTime = SystemAPI.Time.DeltaTime;
Dependency = new CubeJob()
{
deltaTime = deltaTime,
}.Schedule(Dependency);
}
}