Skip to main content

Branch Nodes (Manually)

This guide will walk you through creating branch nodes in Jungle manually. Let's get started!


Step 1: Create a New C# Script

First, create a new C# script in your Unity project.


Step 2: Inherit from BranchNode

Next, make your new class inherit from the BranchNode class. This will form the foundation of your branch node.

using Jungle;

// ↓↓↓↓↓↓↓↓↓↓
public class MyBranchNode : BranchNode<...>
{

}

Step 3: Implement OnStart and OnUpdate

Now, you need to implement the OnStart and OnUpdate methods. Ensure the OnStart method includes the input parameter.

using Jungle;

public class MyBranchNode : BranchNode<INPUT_TYPE>
{
// ↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓↓↓
protected override void OnStart(INPUT_TYPE inputValue)
{

}

// ↓↓↓↓↓↓↓↓
protected override void OnUpdate()
{

}
}

Step 4: Add the BranchNode Attribute

Add the BranchNode attribute to your class. This defines the input and output ports.

using Jungle;

// ↓↓↓↓↓↓↓↓
[BranchNode(
InputPortName = "My Input",
OutputPortNames = new []
{
"My Output 1",
"My Output 2"
},
OutputPortTypes = new []
{
typeof(OUTPUT_TYPE),
typeof(OUTPUT_TYPE)
}
)]
public class MyBranchNode : BranchNode<INPUT_TYPE>
{
protected override void OnStart(INPUT_TYPE inputValue)
{

}

protected override void OnUpdate()
{

}
}

Step 5: Add the NodeProperties Attribute

Finally, add the NodeProperties attribute to your class. This defines additional properties such as the title, description, and category of your node.

using Jungle;

// ↓↓↓↓↓↓↓↓↓↓↓↓
[NodeProperties(
Title = "My Branch Node",
Description = "This is a Branch node.",
Category = "My Nodes/Branch",
Color = Green
)]
[BranchNode(
InputPortName = "My Input",
OutputPortNames = new []
{
"My Output 1",
"My Output 2"
},
OutputPortTypes = new []
{
typeof(OUTPUT_TYPE),
typeof(OUTPUT_TYPE)
}
)]
public class MyBranchNode : BranchNode<INPUT_TYPE>
{
protected override void OnStart(INPUT_TYPE inputValue)
{

}

protected override void OnUpdate()
{

}
}

With these steps, you've created a basic branch node in Jungle. Feel free to customize the input and output types and the properties to suit your needs!