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.
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:
Player clicks on thing.
Relevant HUD Prompt pops up asking what they’d like to do to thing.
Player selects chop down.
On button click casts to event generator which will then fire the relevant event.
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.
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.
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
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?
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:
interact with tree
spawn chopping actor and provide tree information (location)
chopping actor runs event to animate tree falling & and passes resources to player if needed
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!
Edit: Sadly timelines cannot exist in the event graph of actor components. ThompsonN13 and Crisp Clover s’s solution worked perfectly though! Thanks all!
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.