Hey all. By now I’ve posted this to the ue4 sub, it’s been on the answerhub for about a week and I’m honestly at my wits end and super upset at this since I can’t progress any more until I solve this.
I’m trying to make it so players can interact with the HISMs that are generated in the world. I do this by a HUD menu that will popup with the relevant buttons depending on what you’re interacting with. This works pretty well. Right now in the process of resource collection, things like wood, gold, etc, etc…
I have a simple setup to chop down trees and collect the wood. This is used with an event generation master that will spawn a BP Actor to act as a specific event when needed. It will destroy itself when it is done.
My problem is I need some sort of way to re-reference the actor if the player did not finish chopping down a tree, or went and did something else, or was interrupted for whatever reason. I’m attempting to get the player, tree and the cut event actors’s location and check them against each other but it doesn’t seem to work.
Player interacts with tree.
HUD prompt appears.
Chop wood button is hit.
Event master spawns chop wood actor by getting the hit HISMs location.
Tree is chopped down wood pops out every “chop” this works perfectly with the third attempt(as long as the player stays in the exact same spot) and the other two it will only work once.
I am trying to get the players location, the HISM’s location and the cut wood actors location, compare them if similar then don’t spawn and use that one to de-increment the trees’s health.
(1st and 2nd attempt) - (Second branch = True)Any further attempts will spawn another one, but since I’m for looping all actors of class it drops wood exponentially more often. 10, 20, 40, 80, 160, etc, etc… So infinite wood then game crash.
(1st and 2nd attempt) - (Second branch = False)It will not want to spawn another for unknown reasons, and it won’t go off the first spawn as the array length is now greater then 0. Unless the actor is deleted, but since multiple people can chop wood it’s just assumed this would always be greater then 0 after the first spawn.
(https://imgur.com/a/2fo51z0) The closest I've gotten by far is using a sphere trace to detect if the player is overlapping the tree HISM. The problem is a chopped tree is a log on the ground; so a sphere trace will never cover the whole thing unless it is gigantic. which is just gonna mean I can't chop any trees close to each other at all. I need some sort of way to trace along the trees entire collision and then if it has a cut wood actor overlapping(and a player within x range) use that, exact one's functionality. If it does not have an overlapping cut wood actor, spawn a new one so you can use that one's functionality instead. Where mine fails is it will just spawn a new one if the player walks a little bit down the tree's length as it's checking for overlaps in a sphere not the tree's collision. Any help appreciated.