How to execute a task once in a branch with services at tick? (behavior tree)

I want the task to run only once as long as the decorator condition is true.

However the task restarts every 0.5 seconds since the service checks variables every half second.

I’ve tried many things…
-Using “Event Receive Activación” in the service but it was worse because the task is restarted a lot of times more per second than in the previous case.
-Using the “Receive Search Start” in decorator. In this case the task only runs once but then all previous services on the same branch I need to run at tick (checks ) are not working properly…

What can I do?
Thank you very much!!

Hey Ivan3z!

Can we see a little more of this BT/BB? There’s not a single decorator or selector that is going to solve this issue, but it is achievable.

For instance: Can we see what comes before this in the BT? The BB Variables List?
What is the desired behavior you’re looking for? From this I’m seeing “If I have the cube move to the base, if I don’t then go to the cube”, is that correct? And the issue is that the Decorator is checking every .5s and resetting from root? If that’s the case, would you mind posting the code from the Service you’ve written?

1 Like

Of course!! Do you prefer screenshots? Or do I attach the files (.uasset) here?
it’s a little big!!


As you wish I do it!!
Thank you so much!!

Thanks for the quick reply @Ivan3z!

I’m thinking that your issue is going to be within that Service. Would you mind posting the code for it? You can use this website to paste your code if it’s large!

*Disclaimer: This website is not affiliated with Unreal Engine or Epic. Click at your own risk, and be careful with weird links!

1 Like

I hit the solution button by accident…

The behavior is very simple.

1-The paw goes to look for a cube at the enemy base and then brings it to his base…
2-If an enemy is found along the way he shoots him
3-He also moves away from the path of another pawn so as not to collide with each other

That’s all it does!!

ok, i will… i’ll let you know when it’s done

Look… that website did this to my behavior tree… it’s nothing like the original.

I’m going to make some videos of my files… I think that way we’ll finish faster…

Another option is to share the files through my Google Drive.

Sorry for the misunderstanding, Ivan3z!

Yeah, you can’t do Behavior Trees on it, only Blueprints. What I was asking was what’s inside of that Service? The one called BTService_GetCubeOwner? Can we possibly get screenshots of the code inside of there?

If we don’t hear from you tonight, hopefully tomorrow!

1 Like

OK, This is the BluePrint

When you can!!
I’m not in a hurry.
Thank you very much!!

This is a video of the behavior tree… if you need to see more things just ask me. There is no problem!!

Okay Ivan3z let’s try something!

On the service, you’ll want to use Activation AI.

On the Behavior Tree, click on that service and go to the details window and set it like so:
image
Give that a shot and let’s see some magic happen!

1 Like

It does not work. It keeps running many times instead of just once. The paw moves very slowly.

When I use Event Receive Tick AI. That’s when it works best. The problem is that every half second it stops a bit because the task is executed again. This is how my original problem looked.

Here are the shared files on Google Drive. Let me know when you have them.

Ok Ivan3z, thanks for the back and forth with me, really trying to help with this one!

Your original there looks great! I’m actually thinking that the issue is different. Your behavior tree on the right looks like it’s doing exactly what it should, they’re very fast and twitchy. What’s happening is this:

The MoveTo task is giving the paw a destination. They move to that destination and stop.
Upon reaching the destination, the task returns Success, the behavior tree runs through, reaches the end, and restarts from the root, which is what MoveTo is supposed to do. So there’s a new goal!

What the goal should be now is finding a way for your characters to update their destination without stopping their movement.

You might need to use a Simple Parallel but I couldn’t tell you where to use it.

Your problem has been an issue with UE in the past, most solutions I’ve seen involve using C++.

I wish I could help more but I think I’m getting out of my depth. But what I can tell you is what you thought was the problem is not the problem, it’s the MoveTo, and that’s a problem I don’t know how to solve. :frowning:

Try creating a new post with that question! Make sure to include the last video you sent.

2 Likes

Ok I will. Thank you very much for your help and your time.
I am very grateful!! :sparkling_heart:

You are absolutely welcome @Ivan3z! I wish you luck!

2 Likes

This fixes the bug… Now the pawn moves very smoothly. Show it to the development team. Maybe it will help fix the real bug in the next version of Unreal.

Thank you so much for everything!! :sparkling_heart:

You should post a video! I’d love to see!

1 Like

Here it is!!
I see some branches running at the same time, however the pawns behave correctly.
I’ll check that out.

Enjoy the vídeo!!
thx u so much!!

1 Like