Newbie question about available attributes in Entities.foreach loop

This is probably a newbie programming question. In the HelloCube ForEach example I understand the RotationSpeed_ForEach is a component created by the user. But regarding the Rotation in the foreach loop:

Entities.ForEach((ref Rotation rotation, in RotationSpeed_ForEach rotationSpeed) => {})

Is there a list (documentation) for what I can pass in to the ForEach loop by default for an entity?

What you mean by ā€œdefaultā€?
You can pass many components as you need.

If you want to know, which components are used, you can can look entity debugger, and click entities, to see their components.

1 Like

Yeah, I guess I can look in the Entity Debugger. I guess Iā€™m asking if there is documentation for what the default attributes are for an Entity with zero added components.

I donā€™t know what you mean by ā€˜default attributesā€™ but maybe the following will help.

If you CreateEntity() in code then you generally have to add all components yourself.

If you convert an entity from a GameObject then Unity systems may add relevant equivalent converted components. eg. if you convert a GameObject with just a transform it will probably get a LocalToWorld, Translation, Rotationā€¦ maybe (Iā€™ve not checked).

1 Like

Hey thank you! This is exactly what I was asking about. (LocalToWorld, Translation, Rotation) Should I be calling them Default Entity component variables? I guess a default Entity would have nothing? Looking in the Entity Debugger seems to be the way to go.

Yes, there are no default entity components. The Transform conversion system adds those specific components. They will be common because GameObjects always have transforms and they will be added when you do an automatic conversion, but they are not necessary. They have a specific meaning: that the entity has a location inside the world. But you might not always needs that.

If you have a grid based game, it may be more efficient to simply store the coordinates of entities and derive the transform in your rendering code. Or, some entities may be inventory items so they would only need an inventory slot index when they are drawn in your inventory UI. Or an entity could be part of an AI system and its ā€œlocationā€ is a reference to a node inside a finite state machine.

An entity is just an index into some data, but that data could be anything.

6610618--752263--upload_2020-12-11_11-16-32.png
Not as many. 8 at most. including entityQueryIndex and entity.
Any number more than that, you will have to switch to IJobChunk.

1 Like