- Home /
ECS Error in prefab
Hello, i have implemented a simple code in unity using entity component system, all seems to be okey, but when i look the prefab of the object to wich i have added the script. I see this error:
I don't know how to fix that. i leave you the script here
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
public class MovementCTRL : MonoBehaviour
{
public float speed;
}
class MovementManager : ComponentSystem
{
protected override void OnUpdate()
{
//Esta variable, al declararla aquí será la misma para todas las entidaes que llame la función de abajo
float time = Time.deltaTime;
//Al foreach hay que pasarle sólo los parámetros que vayamos a utilizar abajo
Entities.ForEach((Transform transform, MovementCTRL movData) =>
{
if(Input.GetKey(KeyCode.D))
{
transform.position = Vector3.MoveTowards(transform.position, Vector3.zero, 1f);
}
if (Input.GetKey(KeyCode.A))
{
transform.position = Vector3.MoveTowards(transform.position, new Vector3(15, 15, 0), 1f);
}
});
}
}
Other than that, i have a doubt about this way of coding(ECS), is it allways better option than the tradicional one? or there are some scenarios where convencional coding is more optimal ??
The error is something about a GameObjectEntity class. Is that a class you wrote? in that case it'd be good to attach that code as well.
No, its a unity class that is installed when you install Entities package, you have to add this class to the object to make the ECS work on it
Your answer
![](https://koobas.hobune.stream/wayback/20220612212506im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Stop Coroutine itself? 2 Answers
C# library to detect the position of physical objects on the screen 1 Answer
Field Initializer Error 1 Answer
Scriptable Object won't Reset values after play. 1 Answer
A question about references in C# 2 Answers