A consumer of an Event aware on how to retrieve relevant data ... a business model barrier?

Actually we have only Event script with a small payload to be sent, that excludes for example containers like a map.

But a consumer of an Event should know/be aware on how to retrieve relevant data from other sources, like with big containers.

It seems that it misses a kind of component to do it (like a kind of database component) ?

And we don’t have the possibilty to do it directly through globals for example.

I only see actually to make it with the need to communicate back to the event producer entity, so we’ll need to create new event producers in our consumer entity and new consumers in our firstly producer entity to handle this kind of database query.

This could lead to a significant increase in the number of events and complexity.

What could be the best and easyest way to do it ?

1 Like

It’s now reasonable to think that if there’s no answer about several questions about global variables in this forum, it’s because we’re at the border with Amazon services, that is in occurence the AWS Data Exchange … through the fundamental introduction to building games on AWS using Amazon Lumberyard (free course e-learning training), it describes well the architectural benefits of integrating Lumberyard with other AWS services and should perhaps be the first step to take before using Lumberyard. I’m sorry I didn’t follow it from the beginning :roll_eyes:

Hi @Didier,

It depends what your goals are, DynamoDB is a good place for global data storage if you need the data cloud based, which is often the case in many games nowadays. A client side system for persistent storage of user settings can be found in the SaveData gem, this is useful for things such as Save Games.

If you need transient data storage that only lasts throughout the game or simulation session you can use Script Canvas with Script Events. You create an entity that works as the storage and has a Script Canvas graph that receives notifications of value updates through Script Events, you use these to update your variables or request their values.

Hopefully one of these methods is useful for your goals, for me the best situation would be a “Persistent Data” gem that provides all of these services in a convenient location, unfortunately we don’t have something like that at the moment.

1 Like

Hi Luis @LS1 , could it be possible in scipt canvas to use the Mesh of an Entity as a way to R/W global data ?

@LS1 Are you sure about that “you use these to update your variables or request their values.” ?
It seems to me on the contrary that when you re-enter a script with calling through an Event, it has lost all the variables values that was set by a the previously assignement of it’s local variables… all Variable are cleared when coming back into the script. :boom:

If it’s really the case, unless there is a way to make these Script Variables persistent, we can’t do what you propose as all local variables are lost when you try to read them.

Hi @Didier,

I tried this locally just now and it appears to work correctly, I would have to know more how your scripts are being used, one thing you want to avoid is deactivating the entity that is holding your storage for example.

For my test I used two scripts on two separate entities, one I called VariableStorage and one VariableQuery.

VariableStorage:

VariableQuery:

(Script Canvas) - STORED: 1.0000
(Script Canvas) - QUERY RETURNED: 1.0000
(Script Canvas) - STORED: 2.0000
(Script Canvas) - QUERY RETURNED: 2.0000
(Script Canvas) - STORED: 3.0000
(Script Canvas) - QUERY RETURNED: 3.0000

Edit: here’s the Script Event setup I used:

@LS1 Thanks Luis for this test and effectively we can use that way for small unique data.

But in reality, when using global data, it’s for relatively static data but bigger than a simple Variable number and we can’t use even simple like Variable Arrays in the parameters inside the Node Event.

As you asked more on the script I’m doing, one thing effectively I want is "to avoid deactivating the entity that is holding my storage ".

In brief to tell you more about my scripts, I have a Parent-Children hierarchy of entities that call successively each other in cascade in order to require a treatment on a data at a below level.

The event-driven approach is always the same with a raise of a request Event from the top Entity; then Entities Services that are listening to that Event raise a Confirmed Event when they have done their job after calling their chidren entities … thus a cascade of Events that works perfectly well.

As I wrote, when you come back with a new Event inside a script already activated during a precedent Event, it’s local variables aren’t persistent any more and those variables are numbers and Arrays of numbers (by the way, the “For Each” node could return the index value on Array …)

As when @_AhmadKarami already use coord of entities, why can’t we have a kind of mesh to represent arrays and use it as globals arrays ?

Thus the scope of Variables and persistency is at the center of this discussion and should be covered by an event-driven design explainations with a kind of cook book/best practices in LY scripts that’s currently missing from the LY doc.

1 Like

I’ve seen @_AhmadKarami’s ingenious use of transformation values as variable storage, it’s quite clever. I would solve this issue with a C++ component that provides the variable storage and event buses that allow setting/receiving the variable data (similar to how the TransformComponent works).

2 Likes

@LS1 Super :+1: … seems perfect.

Mr @LS1 & Mr @Didier , I think the issue, Its name is abbreviated :face_with_monocle: SAKGV => Solve Ahmad Karami’s Global Variables , If this c++ component via EBus has a zer0 payload or small payload and supports all types of data( 1ne value / 3ulti value like array), the result will be great or good :thinking:

Mr @Didier & Mr @LS1 types of data with The number of members is very high, for example, an array of 1000 members (entities position), the result should be good, in one level with my experience,
Hundreds of artificial intelligence or 1,000 enemies artificial intelligence are attacking me. The grenade must examine/explode their distance and radius with the array of enemies positions(less 5 meter + foreach+Vector3D.Distance(Grenade.Position,arrary[index].Position)), if not we must think Sphere raycast or Cube raycast for GetListEnemies…
I hope you understand what I mean, excuse me , I can not write english very well :blush:

For info, I’m already playing with vertex inside a mesh of an entity that serves as a big array of global/persitent data.

It already exists a VertexContainer, that is a container of vertices of variable length, with all of what we need like get, set, clear, remove, …

Each vertex point of the mesh has a position that you can get/set through it’s index and thus mesh can serve as a very big global Array.

The starting point is here for updating the global Array with an index:
/**
* Update a vertex at a particular index.
* @param index Index of vertex to update.
* @param vertex New vertex position.
* @return Was the vertex at the index provided able to be updated.
*/
virtual bool UpdateVertex(size_t index, const Vertex& vertex) = 0;

or getting a value from this global Array
/**
* Get a vertex at a particular index.
* @param index Index of vertex to access.
* @param vertex Out parameter of vertex at index.
* @return Was the vertex at the index provided able to be accessed.
*/
virtual bool GetVertex(size_t index, Vertex& vertex) const = 0;

It’s in the VertexContainerInterface.h file.

As an example, the VertexContainerInterface is also already implemented by the Spline component and Polygon Prism component EBuses.

The simplest way is to reuse this example in Lua seen here https://docs.aws.amazon.com/lumberyard/latest/userguide/component-vertex-container.html ) … thus reusing this EBus Request Bus Interface Example.

This solution is uncompromisingly fast and easy to use and it’s the raison why I proposed Luis @LS1 to consider it as a possible way for new script nodes.

Last solution but not least solution : we can introduce our glogal data inside tags, by using the tag component on Entities.

Too those Entities could be generated through spawn in order to create things like Array or Map containers at the size that we need.

For example, each Entity will bring with it several Tags that could simulate keys/data, and we have the existing node that allows us to get entities according to a tag like key in containers, and also delete, clear, …
image
image
@_AhmadKarami did you aleady test the sphere raycast solution that you propose ?

1 Like

Mr @Didier , It is Fun & Smart for your idea about global data , plus , No , I did not test the sphere raycast ,cause I see , The bugs I sent will not be fixed in recent versions, so I didn’t test the nodes anymore.

Mr @Didier , of course , I used this nodes (GetEntitiesByTag node and much more), I think , this is a good example for script canvas … I hope useful for you & people :slightly_smiling_face: I added a video tutorials playlist for GDC 2020 & this Zip file LY 1.23 Project AhmadKarami.zip (3.4 MB)
https://www.youtube.com/playlist?list=PLGiO9ZyED9TMH4fMy5rttmWQRq0EmJKjR