forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotationSpeedSystem.cs
More file actions
25 lines (24 loc) · 1.04 KB
/
Copy pathRotationSpeedSystem.cs
File metadata and controls
25 lines (24 loc) · 1.04 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
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
namespace Samples.HelloCube_01
{
// This system updates all entities in the scene with both a RotationSpeed and Rotation component.
public class RotationSpeedSystem : ComponentSystem
{
protected override void OnUpdate()
{
// ForEach processes each set of ComponentData on the main thread. This is not the recommended
// method for best performance. However, we start with it here to demonstrate the clearer separation
// between ComponentSystem Update (logic) and ComponentData (data).
// There is no update logic on the individual ComponentData.
ForEach( (ref RotationSpeed rotationSpeed, ref Rotation rotation) =>
{
var deltaTime = Time.deltaTime;
rotation.Value = math.mul(math.normalize(rotation.Value),
quaternion.AxisAngle(math.up(), rotationSpeed.RadiansPerSecond * deltaTime));
});
}
}
}