How can I create a global variable in Script Canvas? [Lumberyard 1.14]

I defined a variable in AreaTrigger Entity (Script Canvas) with name Ammo1 variable.
How can I use this variable(ammo1) in another Entity (MyPlayer Entity)?
Basically, how can I create a global variable in Script Canvas?
I think All variables are private in ScriptCavas,How to get my variable in another entity?

I using Lumberyard 1.14, also I making a game with script canvas , I hope receive my answers soon, please add a lot nodes to script canvas , Disappointed with these nodes,Because the number of nodes seems to be very low.

I found but I implemented with a other way but my answer is remain.

if persons/person is/are here , you have this problem , You can use this method instead of the variable/variables:

I made Empty Entities for each weapon , I use of SetLocalX / GetLocalX ,SetLocalY / GetLocalY, SetLocalZ / GetLocalZ nodes , etc for implementation ammo value, also relation to different graph sections.

In fact, each Entity is a variable, or each x , each y , each z are three variables , etc :slight_smile:
I’m really smart :wink:

I was asking myself the same question lately …it seems to me more in the spirit of Lumberyard to use here Events on an entity, empty or other entity already in place, which will contain the global variables that can be in this way in unlimited quantity and of all types like a matrix for example and callable from any other script.

1 Like

You can use script events. Make an event for setting and getting the variable. Anytime you want it just catch that that event catch it in script with the event node for that script event. And every time you set it it will then fire that event wherever that event is placed.

Script events is how you pass around data

1 Like

I found this solution for lumberyard 1.14, global variables could not be used in lumberyard 1.14 :blush:

We can use script events(Send/Rec global variables) for lumberyard 1.24 now :wink:

Yes, it’s true , global variables & script events :slightly_smiling_face:

@_AhmadKarami except you can’t put a container in a Send… and it’s often this type of global variable container that we need the most.

In my opinion, there is actually in this 1.24 a lack on this global variable part, as well as on simple things like a complete FiFo node useful to manage asynchronisms such as with Events that modify the current data in a script and basic Maths nodes.

1 Like