Can anyone explain nodes to me? I'm a bit lost

Yeah, so basically the title says it all, anybody have any hints or maybe a tutorial about managing scripting. I’ve messed with the menu, but am unsure how to make things work. Seems fairly complicated, but I’d really like to figure it out.

1 Like

well yesterday i made a giant buzzsaw by scaling a cylinder flat and increasing its diameter. i added triangle blocks as teeth so it looked dangerous. then i grouped all the items together. i cycled parent objects until the cylinder was the parent object so i could make it spin using scripting. then i saved it as a prefab. i found out that my static/scalable prefab buzzsaw was not able to be an Object for Input to a Node.

Today i am going to try making a prefab out of only dynamic objects. Then i will see if i can set my Dynamic Prefab as an Object to Input into a Node.

I think of the nodes like spaghetti and meatballs.

And it can get just as messy.

Each node (meatball) runs an action of code (eg. adding numbers or setting what gun a player holds).

The nodes are connected by wires (spaghetti). These control the flow (order) of the script as well as carry data to the nodes.

The flow is through the diamond (or action) pins.

The information is through the circle (or data) pins. Data can be numbers, strings, or objects (which includes players).

Node graphs are event based. So they sit the background waiting to be triggered by an event. eg. On Player Killed, On Round Start, On Object Enter Area.

Here is a pic of my first script that I did yesterday. It had to be the traditional “Hello World”.

https://drive.google.com/file/d/108kT2pmnbd0TRSyW1Tu5165If00nF-EX/view?usp=share_link

The script waits for it’s event - On GamePlayStart.

You can see the action wire goes from the event to “push splash to player”. Diamond to Diamond. Which essentially pops up a message to the player at the beginning of the game.

The splash nodes needs three bits of data. A player (chosen randomly here), a duration (entered in the node - but could have been passed from another node), and the message. Data flows circle to circle.

The message is created in it’s own node and involves defining the template and taking two data strings.

The Player input here is left empty - but other message templates can include a Player’s name.

The end result is that at the start of the game, one random player (ie. me because I am testing this by myself) gets splashed with “Hello World” at the start of the game.

1 Like

That was the worst analogy ever and made absolutely zero sense but explained the system perfectly and should be the official tutorial for nodes and scripting :rofl::rofl::rofl:

2 Likes

we will get better at this.

1 Like

I kind of think of it as a bit of programmer humour.

We usually try and avoid “spaghetti” code (that splits off and goes in multiple directions).

But here we are. :slight_smile:

1 Like

The other interesting behaviour that can trip you (or maybe just me) is that each action node (diamond) recalculates all the incoming data paths.

I did this simple script just then as an experiment;

https://drive.google.com/file/d/1-rUeXDQIIQIJyYYX9nwBEUIaM0iuSG3t/view?usp=sharing

It sets up a local variable called “count”. And then waits for two in game events.

  1. When your Spartan marks a spot on the map it takes this variable and simple prints it to the killfeed. So, at any time, we can check it’s value.

  2. When your Spartan crouches it adds 5 to the variable and then prints it out to the killfeed.

So on testing the script;

I spawned in and marked a spot on the ground. The killfeed showed “Debug: 0.00000” as expected.

I then crouched - and what do you think showed up in the killfeed?

I assumed it would be “Debug: 5.00000”.

But no. It shows “Debug: 10.00000”.

But if I mark the ground again it shows “Debug: 5.00000”. Which is the actual value of the variable that we were expecting.

What happens is that the first action node is “set variable” - so it follows the data path from the top; reading the variable (zero) and adding 5 before saving. Exactly as we expected.

The next action node is “print to killfeed”. So the path starts again from the beginning. It reads the variable (which is now 5), adds 5 (making it 10), and then prints it out.

Spaghetti indeed.

PS. In case you wondering “on crouch” triggers twice - once for going down (player crouching is true) and again for coming up (player crouching is false). If you don’t check then it would have executed twice for each crouch and been very confusing.

Ya as a programmer I found it a very entertaining choice of analogyz.

1 Like

i set myself some goals and its helping me figure out the node features.

i made a scripting playground map and i keep going back to it to try to figure out how to do very plain things, like move a cube only up and down.

or like,

rotate a cube only 45 degrees

and like as dry as i could imagine, interact with a switch in game, it rotate the cube 45 degrees.

from this i have learned much about how nodes work.

1 Like

That’s definitely the best way to attack it.