How to use the same event multiple times at the same time?

Hey all. I’m trying to implement a tree chopping system the player can use, it works pretty great except I can’t seem to fire it at the same time.

So say player 1 chops a tree, and player 2 does nothing it works good.

Player 1 chops tree but then another player goes to chop a tree the function will then stop midway through tree 1 and start on tree 2.

If player 1 chops a tree but then shoots another one down the function will stop and then start on the other one. It seems completely unable to fire the event multiple times simultaneously.

How can I make it so it just fires a “new” instance of the event? All my gameplay events are stored in a master bp that is just referenced when you need one fired.

Any help appreciated.

Personally you can do DoOnce but I think the problem is a little bit more complicated than that, can you show some screenshots that way I can understand the problem more accurately.

It’s spread across a couple different blueprints but it’s basically this:

  1. Player clicks on thing.
  2. Relevant HUD Prompt pops up asking what they’d like to do to thing.
  3. Player selects chop down.
  4. On button click casts to event generator which will then fire the relevant event.
  5. Event plays, tree chopped, etc etc…

But this can be interrupted by something else calling this same event. So if I start to chop down a tree and someone else or an ai comes along and chops down a tree it quits my event and restarts at the new tree.

So I’m trying to figure out how to fire the event again while letting the one currently firing go.

It’s spread across a couple different bps so not really. It basically is this:

  1. Player selects thing.
  2. Relevant HUD Prompt appears asking what player would like to do.
  3. Player selects option.
  4. HUD calls to event generator master and it will choose what event to fire based on the button press.

If the same event is ever called twice, at the same time, it will stop wherever it is currently being fired and restart on the new tree.

I sue HISMs for my level’s actors so that’s not a good solution. That would require every actor in the level to have their own blueprint. Which would just absolutely demolish my resources.

All my gameplay events are stored in a master bp

That sounds like the problem right there. Building the functionality inside the corresponding objects should get rid of your problem. A tree can be chopped, so you should build an event there (e.g. “IsChopped”); you can also build an event inside the player (e.g. “IsChopping”). As always, feel free to ask more questions :slight_smile:

Ah, true. I forgot about that. How about: Spawning a data only Actor when chopping starts, and handling the logic there until chopping stops, then destroy the actor?

Why not keep ChopWood in the player class? Sounds like the most natural approach, no?

the issue is that you need a event to be running for every tree that is being worked with, so multiple instances of the function you are running.

since your using HISMs and not actors which is understandable then i would spawn a actor when you interact with the tree. this actor would simply have the function to control the movement of the mesh and information about its location.

so it would be something like:

  1. interact with tree
  2. spawn chopping actor and provide tree information (location)
  3. chopping actor runs event to animate tree falling & and passes resources to player if needed
  4. chopping actor destroys self.

this will enable you to still use hisms and get the performance benefit of them but still get the multiple events working at once. true there will still be a slight performance penalty for spawning a actor but if its a singular actor and it doesn’t have any components to render then it really doesn’t take and performance at all to spawn.

Hmm! That sounds like a decent way to do that! So maybe I’d have my event generator drop that actor, it runs it’s function and kills itself. I’ll come back to update but this seems like a perfect solution! Thanks!

Thanks! This is the approach I’ll try!

Oh ■■■■ that sounds even more baller!

Edit: Sadly timelines cannot exist in the event graph of actor components. ThompsonN13 and Crisp Clover s’s solution worked perfectly though! Thanks all!

opps sorry CrispClover i posted almost the same thing as a answer, while i was typing you beat me to it haha

No worries, your answer explains it in depth, which is how I was able to ninja you :smiley:

One can also dynamically spawn actor components. This way a single actor can run multiple instances of the same function embedded within. What’s more, the component can be made responsible for removing itself and perform additional task while it’s active.