forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotationAccelerationSystem.cs
More file actions
29 lines (26 loc) · 914 Bytes
/
Copy pathRotationAccelerationSystem.cs
File metadata and controls
29 lines (26 loc) · 914 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
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Burst;
using Unity.Mathematics;
using UnityEngine;
namespace Samples.Common
{
public class RotationAccelerationSystem : JobComponentSystem
{
[BurstCompile]
struct RotationSpeedAcceleration : IJobProcessComponentData<RotationSpeed, RotationAcceleration>
{
public float dt;
public void Execute(ref RotationSpeed speed, [ReadOnly]ref RotationAcceleration acceleration)
{
speed.Value = math.max(0.0f, speed.Value + (acceleration.speed * dt));
}
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var rotationSpeedAccelerationJob = new RotationSpeedAcceleration { dt = Time.deltaTime };
return rotationSpeedAccelerationJob.Schedule(this, 64, inputDeps);
}
}
}