Hi,
I feel very stupid, but I could not get that simple Rotation System to work.
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Collections;
using Unity.Entities;
using Unity.Transforms;
using Unity.Mathematics;
using System;
using System.Runtime.CompilerServices;
public class OneRotationSystem : ComponentSystem {
public struct CubeGroup {
public ComponentDataArray<Rotation> cubeRotation;
public EntityArray Entities;
public readonly int Length;
}
#pragma warning disable 649
[Inject] private CubeGroup cubeGroup;
#pragma warning restore 649
protected override void OnUpdate()
{
float dt = Time.deltaTime;
float speed = 100;
for (var i = 0; i < cubeGroup.Length; ++i)
{
var rotation = cubeGroup.cubeRotation[i];
rotation.Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), dt * speed));
}
}
}
My entities, have Position, Rotation and MeshInstanceRenderer Components. I have instantiated them and I see them in the scene, but I could not modify the rotation, I have a feeling that something is overwriting the old value every frame I try to modify it.
I am using Unity 2018.3b11 and the latest Entities version available in the Package Manager.