Search Issue Tracker

Active

Votes

0

Found in [Package]

1.0.12

Issue ID

BEHAVB-341

Regression

No

Cloned scene agent shares graph instance due to SceneProcessor Pre-initialization

Package: Unity Behavior

-

*Steps to reproduce:*
# Create a new BehaviorGraph and open it
# Disable the OnStart Repeat 
# Connect a LogMessage and SetVariableValue to the OnStart node
# Assign a BlackboardVariable<String> to both node with a default value "Hello World"
# SetVariableValue node set the string to "Invalid"
# Attach the Graph to a GameObject in the scene
# Create a script with the provided code and attach it to a GameObject in the scene, then assign to it the agent Gao as Prefab
# Enter playmode and press space several times

*Actual results:* 
* Hello World
* Invalid
* Invalid
* ...

*Expected results:* 
* Hello World
* Hello World
* ...

*Reproducible with versions:* 1.0.12, 1.0.7

 

*Code:*
{code}
public class CloneAgent : MonoBehaviour
{
    [SerializeField]
    private GameObject m_Prefab;
    private GameObject m_Instance;

    private void Awake() => m_Prefab.SetActive(false);

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Clone();
        }
    }

    private void Clone()
    {
        if (m_Instance != null)
        {
            Destroy(m_Instance);
        }

        m_Instance = Instantiate(m_Prefab);
        m_Instance.SetActive(true);
    }
}
{code}

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.