您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
35 行
725 B
35 行
725 B
using Unity.Entities;
|
|
using Unity.Jobs;
|
|
using Unity.Mathematics;
|
|
using Unity.Physics;
|
|
|
|
public class IncreaseVelocityOverTimeSystem : JobComponentSystem
|
|
{
|
|
protected override JobHandle OnUpdate(JobHandle inputDeps)
|
|
{
|
|
float deltaTime = Time.DeltaTime;
|
|
|
|
JobHandle handle = Entities
|
|
.WithReadOnly(deltaTime)
|
|
.ForEach((ref SpeedIncreaseOverTimeData data, ref PhysicsVelocity vel) =>
|
|
{
|
|
float modifier = data.increasePerSecond * deltaTime;
|
|
float3 newVel = vel.Linear;
|
|
|
|
if (newVel.x > 0)
|
|
newVel.x += modifier;
|
|
else
|
|
newVel.x -= modifier;
|
|
|
|
if (newVel.y > 0)
|
|
newVel.y += modifier;
|
|
else
|
|
newVel.y -= modifier;
|
|
|
|
vel.Linear = newVel;
|
|
|
|
}).Schedule(inputDeps);
|
|
|
|
return handle;
|
|
}
|
|
}
|