Пример #1
0
    //Copy transform and rigidbody data to m_actorDataArray
    public void WriteActorDataArray()
    {
        for (int i = 0; i < m_actorNum; ++i)
        {
            ref BehaviorPlugin.ActorData actorData = ref m_actorDataArray[i];

            // Get the leader's root joint transform because its controlled by keyboard
            if (m_actorList[i] == m_leader)
            {
                GameObject root = m_leader.GetComponent <FKIKCharacterController>().m_root;
                actorData.globalPosition = PluginHelpFunction.Vector3ToFloatArray(root.transform.position);
                actorData.globalRotation = PluginHelpFunction.QuaternionToFloatArray(root.transform.rotation);
            }
        }
Пример #2
0
    public void ResetPlugin()
    {
        m_actorNum = m_actorList.Count;
        BehaviorPlugin.InitializeBehaviorPlugin(m_actorNum, m_obstacleNum, (int)m_behaviorType);
        int gainNum = BehaviorPlugin.GetGainNum();

        BehaviorPlugin.SetControllerGains(m_gain.GetGainFloatArray(gainNum), gainNum);

        m_actorDataArray = new BehaviorPlugin.ActorData[m_actorNum];
        for (int i = 0; i < m_actorNum; ++i)
        {
            m_actorDataArray[i] = new BehaviorPlugin.ActorData(i);
            m_actorDataArray[i].globalPosition = PluginHelpFunction.Vector3ToFloatArray(m_actorList[i].transform.position);
            m_actorDataArray[i].globalRotation = PluginHelpFunction.QuaternionToFloatArray(m_actorList[i].transform.rotation);
        }
        SetLeader(m_leader);
        ClearObstacles();
        if (m_behaviorType == BehaviorType.AVOID)
        {
            GenerateObstacles();
        }
    }