该项目是使用Unity DOTS 实现的经典 Pong 游戏的简单实现。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

25 行
608 B

using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
public class PaddleMovementSystem : JobComponentSystem
{
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
float deltaTime = Time.DeltaTime;
float yBound = GameManager.main.yBound;
Entities
.ForEach((ref Translation trans, in PaddleMovementData data) =>
{
trans.Value.y = math.clamp(trans.Value.y + (data.speed * data.direction * deltaTime), -yBound, yBound);
}).Run();
return inputDeps;
}
}