forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGravitySystem.cs
More file actions
26 lines (24 loc) · 690 Bytes
/
Copy pathGravitySystem.cs
File metadata and controls
26 lines (24 loc) · 690 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
using Unity.Entities;
using Unity.Jobs;
using Unity.Burst;
using Unity.Mathematics;
using Unity.Transforms;
namespace Samples.Common
{
public class GravitySystem : JobComponentSystem
{
[BurstCompile]
[RequireComponentTag(typeof(Gravity))]
struct GravityPosition : IJobProcessComponentData<Position>
{
public void Execute(ref Position position)
{
position.Value = position.Value - new float3(0.0f, 9.8f, 0.0f);
}
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
return new GravityPosition().Schedule(this, inputDeps);
}
}
}