How to cancel ongoing interaction with a smart object?

I have a behavior tree task which calls function “Move to and use smart object with gameplay behavior” in “Receive Execute AI” event.

The interaction with smart object works as intended but I need to stop the interaction in certain cases. Aborting the task doesn’t work because it continues the interaction until it finishes executing. I also tried using function “Mark smart object slot as free” in “Receive Abort AI” event.

But it doesn’t make any difference - the interaction continues executing. Also, in this case, I get this error:

So it seems that the smart object slot is still not released properly.

I would appreciate any help as I’m out of ideas.

I am aware that this post is a couple of month old, did you find a solution? I am in the same situation currently.

Hello!

There is a Behavior Tree task available that will handle SmartObject interactions called Find and Use Gameplay Behavior Smart Object. The task handles being aborted as well, and it should be used as the example of how to do this if you want your own custom task.

For your example BP, you should store the async task returned by Move to and Use Smart Object with Gameplay Behavior node into a variable. When you receive an abort or other logic you may have that should stop the interaction, you need to stop the async task by using End Task with the async task as the target. From looking at the code, I believe this will also handle stopping the gameplay behavior running on the Pawn.

-James

In my experience, cancelling the task from MoveToAndUseSmartObjectWithBehavior does not stop the behavior. The best solution I’ve found is to fire an event on the player from the behavior when it starts. I bind to this event in my custom Use Smart Object State Tree Task and abort the behavior on leaving the state.

Event:

Fired from the behavior on trigger:

I bind to it before starting the behavior in my task and then save on the reference and unbind:

It’s not the most elegant but it works!