Forum rules - please read before posting.

Performance issue when using ActionListAsset.Interact() method

Hello World !

I am back with an other issue.

Context : I have an AI in my scene that has a public ActionListAsset attribute. On some conditions, it performs the actionListAsset interaction by calling 'myActionList.Interact()'.

My problem : This previous call takes a lot of time to be performed, mainly because the engine calls the 'Object.FindObjectsOfType()' function for each Action in the ActionListAsset.

Here is a screenshot from the profiler :

I don't know well how Scriptable Objects work, but maybe I am missing something concerning the instantiation that could help me avoid all these calls.

AC Version : v1.65.0

Thank you !

Comments

  • It's a necessary call, because it needs to find the character in your scene who's speaking the line of text you're giving them.

    You should be able to avoid this, however, by using a GameObject parameter in place of the Dialogue: Play speech Action's Speaker field, and then setting that parameter's value through script before calling the ActionListAsset's Interact() method:

    actionListAsset.parameters[0].gameObject = myAICharacter;
    

    (Assuming the GameObject parameter is the first in the index, and "myAICharacter" is a reference to your character in the scene)

  • Thank you for the answer. Assigning the parameters actually removed all the Object.FindObjectsOfType() calls !

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.