0 votes
asked in InteractionSystem by

Hi there, I have a simple scene with two interaction objects I want to trigger simultaneously. Rather than use the InteractionSystemTestGUI script with buttons ( though the interactions worked) I've written another one which plays interactions automatically, based on the docs:


using UnityEngine;
using System.Collections;
using RootMotion.FinalIK;

[RequireComponent(typeof(InteractionSystem))]
public class MultipleInteractionSystemTestGUI : MonoBehaviour
{


    private InteractionSystem interactionSystem; // Reference to the InteractionSystem component on the character
    public FullBodyBipedEffector m_effector;
    public InteractionObject m_object; // The object to interact with
    public bool interrupt; // If true, interactions can be called before the current interaction has finished

    private void Start()
    {
        interactionSystem = GetComponent<InteractionSystem>();
        StartCoroutine(Trigger());
    }
   
    IEnumerator Trigger()
    {
        while ( interactionSystem == null )
        {
            yield return null;
        }

        interactionSystem.StartInteraction(m_effector, m_object, interrupt);
    }
}


Initially Final IK complained that 'The InteractionSystem has not been initiated yet.', I added it into a coroutine to check against this. However, I'm still getting the error with the above code. Any ideas where I'm going wrong?

Many Thanks

1 Answer

0 votes
answered by (22.8k points)

Hey,

Please go to InteractionSystem.cs line 607 and change private bool initiated to:

public bool initiated { get; private set; }

Then check for !interactionSystem.initiated instead of interactionSystem == null in your coroutine.

Another option would be to set your script to a higher value than InteractionSystem has in the Script Execution Order. That way your Start would run after InteractionSystem::Start

Best,

Pärtel

Welcome to RootMotion Q&A, where you can ask questions and receive answers from the developer of Final IK and PuppetMaster and other members of the community.

Post as a guest, create an account or login via Facebook.

Please use the correct category when you post your questions.

...