Lesson 02-Make Global Variables in Script Canvas-Smart tutorial-Lumberyard 1.14

I’m Back to forum

Before I begin this lesson , I would advise you , see this two issue , good questions and good answers:

A floating Player in Script Canvas Lumberyard 1.14:

https://forums.awsgametech.com/t/zero-gravity-level-is-it-possible/5285/1

Zoom In / Zoom Out in Script Canvas Lumberyard 1.14:

https://forums.awsgametech.com/t/input-bindings-does-not-support-mouse-wheel-up-down/5291/1

if you saw Lesson01 , I showed to you , how to make a simple player (FPS and TPS) .

This is a clever trick because there are no global variables in script-canvas and all variables are completely private in script- canvas , but do not worry , I show to you , how to make global variables in script-canvas.

Let’s get to work :

The basis of making global variables is this image,please first see this image:

You can actually access three variables by building each empty entity.
I used in this example only x translate property in Transform Component, also you can use y and z , also make other empty entities for make global variables , this is very very easy :wink:

Step01- Change Day Time to Night Time with Time of Day , Tools ->Other->Time of Day

Step02-Right Click on the Terrain , then , make a Empty Entity (Select Create Entity Option) ,change Entity Name to “Trigger”

Step03-for Trigger Entity ,Click on Add Component Button , search “Trigger Area” Component , then add this component , plus , add “Cylinder Shape” component , then , add component “Script Canvas” , and finally Add “light” component

Step04- for Trigger entity , you implement this graph with name

SetTriggerArea , then Load SetTriggerArea.scriptcanvas file inside ScriptCanvas component ,

Step05- Right Click on the Terrain , then , make a Empty Entity (Select Create Entity Option) ,change Entity Name to “MyVar” , that’s all :slight_smile: , this empy entity is a role for global variable , x in translation property - transform component :wink: , and I changed x = 59

Step06–for Player Entity , add component “Script Canvas”

Step07-for Player entity , you implement this graph with name GetTriggerArea , Load GetTriggerArea.scriptcanvas file inside ScriptCanvas component

Step08- Play and Enjoy (Ctrl + G)

6979-global-variable-in-script-canvas-lumberyard-114-ah.jpg

if you had questions/problems let me know

I update Robot Island Project soon :slight_smile:

With respect

Ahmad Karami