27 lines
775 B
C#
27 lines
775 B
C#
|
|
using Unity.Entities;
|
||
|
|
using UnityEngine;
|
||
|
|
using Unity.Mathematics;
|
||
|
|
|
||
|
|
namespace HappyForest.Prototypen
|
||
|
|
{
|
||
|
|
public class PilleAuthoring : MonoBehaviour
|
||
|
|
{
|
||
|
|
public float speed = 5f;
|
||
|
|
|
||
|
|
// Der Baker wird von Unity automatisch beim Start ausgeführt
|
||
|
|
class PilleBaker : Baker<PilleAuthoring>
|
||
|
|
{
|
||
|
|
public override void Bake(PilleAuthoring authoring)
|
||
|
|
{
|
||
|
|
var entity = GetEntity(TransformUsageFlags.Dynamic);
|
||
|
|
|
||
|
|
// Wir fügen der Entity unsere reinen Daten hinzu
|
||
|
|
AddComponent(entity, new PilleWanderData
|
||
|
|
{
|
||
|
|
Speed = authoring.speed,
|
||
|
|
Direction = new float3(1, 0, 0) // Startrichtung
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|