Structure Info?

Hey I have made a structure and in the game, like any structure, it shows who is the owner and personal owner but how can I get this info in event graph? I think I have tried everything. I tried a work around. I tried saving the owner on event begin play and it works when the player first hits the button for showing the structure but then once you place structure to a snap point it erases all the data, this happens on every structure I have tried, even the original core items. What happens is that Event Begin play actually fires twice, first when you first click the button for a structure, such as getting ready to place the structure, and second once you have actually place the structure and its during this second event firing that resets all the data. So is there no other way, has anyone else had issues with this? In addition, it’s also as if the reason the event fires twice is because the game is actually making a second structure/instance. I say this because when debugging I used get all actors of class and I watched the array for each event and it increases the instance number by 1 each time so its like I add one structure to the game yet the array increases the number of instances at puts it at 0. Quick example if that sounded confusing is if I use get actor owner and it gives me a long name, at the end there is a digit, like player1, player2, and so on. So if I add my first structure it should be at 1 and stay like that but when I place the structure to snap point/actually create it, the number will go up to 2 and store it at array[0]. Don’t know if this is a bug or what but there has to be a way to get the info since the game always displays the owner of a structure.

Any help would be appreciated.

I went to the StorageBox_Fabricator blueprint and went to event-graph and right-clicked and found “Get Owner”. Is that what you are looking for? I’m relatively new to UE4 so I don’t know what I’d cast that to, or if its even the right function, but it’s there.

Yea I already did that, and it is one of the functions that gets the info but then erases after the second firing of event begin play. I even used it on begin overlap and it just says none. This is frustrating lol

Actually, I just thought of something, going to go try now

Let me know what you try. Have you thought of saving it into a variable so you don’t have to call it every time?

I been having somewhat the same problem with structures.
How to check if the structure is a spawn emmiter. "green/red model" - Support - Unreal Engine Forums
My problem is that i need to prevent the 1st Begin Play event from beeing fired or have some logial code in it so it doesnt execute my stuff in there.
It really anoys me that it fires the Begin Play event when the structure is preplaced out.

If you find a solution. please post it since i need something like you do.

About the owner thing, I think it is as simple and checking the “Targeting Team” value. I thought that I had ruled out that possibility before, but it seems to be the value that determines the owner of stuctures. It is shared among pawns and structures, owned by the same guild.

EDIT: hmm can’t read the value for other actors through a graph though. It will just return the value of ‘self’ every time, even when linked to another actor.
EDIT2: Or not, it just seems that the debug information is wrong, but if you actually use it for something it will check the proper value of the other actor it seems.

So you want it to ignore the second “begin play”? Perhaps is there a way to save a counter as a variable between the two iterations? The first time it fires, a counter can equal one, and at the end of the code, if it is equal to one, then save the info. The second time it fires, have it equal 0, and if is else than 1, ignore the save process.

I haven’t tried making structures at all, so I do not know how the events work while placing, but perhaps if there is a way to save that number local to the player, then that could solve your issue.


And even better, you could just use a boolean variable called “firstbegin” or something to save on memory for a more optimized blueprint.

@Newkz i will try that and see what I come up with.
@Paranoid_Giraffe yea tried that too already and it doesn’t help. For some reason it still erases everything even though I set it not to save on the second event firing. That’s what’s killing me, I can always find a work around for an issue but this one is just behaving weird, no matter how I set it up it always erases the data I tried to save. A possible solution is what I tried with saving, what you mentioned also, and save it in another object like the player but I am trying to avoid modding any core items, such as the player, so that it can be used with other mods. I want all the mods I make to be stackable with others.

@ Paranoid_Giraffe

The problem with that is that you cant save the variable on the actor itself. since it gets destroyed and therfor its variable aswell.
Storing the value on the player means it requires a change to the player bp. this sound like a bad idea to do.

This will not really work as a stackeble mod. how can you ensure be sure that users is loading the mods in correct order if mutltiple mods used.
You never know if some new moding is added after and overwriting the player bp with its own variables and values.

My idea was to try to get the material used. if the structure has a spawn emitter it uses another material.
Since we know the standar material and texture used on the model it should be a simple copmarison.

Like using. Get Material Name and see what returns and compare that to what it should really be.
But as i said in my own thread. this metode only crashes my dev kit.
well. last time i tried to use Get Material Name was in 1.97. , i gave up on it after that. i do no see anything in the change log that has fixed this eitgher. so im sick of crashes.:stuck_out_tongue:

Okay, thanks to Newkz I think I might have fix this. Targeting team does give a number that is identical to player but its like around 8 digits long so it might mean something else. Either way if this is how the game stores owner ship then its the solution, All we have to do is check to see if targeting number is the same on an object as is the person interacting with it to check for ownership. Need to test if a lil more but if this works it would be amazing, and all thanks to you pointing it out Newkz :smiley:

Seems to be working all though it acts weird. Like you said earlier it shows in the graph the same number but when actually testing it, results seem to be different. However, I only tested against a static mesh player but it still works. Thanks a bunch man, I owe you :slight_smile:

So I had a chat with Arkman/nuxil and I found a solution for your issue. Haven’t read the thread at all, but he told me that this is a thread where my solution would fit. So forgive me if that is not the answer you are looking for.

The delay is important since the material assign script (where ever that is located) is firing after the beginplay is firing. So without delay it would not work.