When the controller knows its pawn?

I want to add a tag to the pawns from the Game Mode.
Everything I tried doesn’t work.

In the end I have noticed that there is a desynchronization between the spawning moment, and the possession of the pawn by the controller, and the event Possessed execution moment.

So when the possessed event is executed the controller still doesn’t know anything about its pawn. (Get Controlled Pawn does not work)

However if I wait just a second then everything works fine.

So I need to know when everything is well synchronized to make a correct request to the server. Because the use of “delay” I think is a wrong solution.

Is there any event or method that allows me to know when everything is in sync?

Thank you very much!!

Can you describe the flow of logic you are going for?

Are these actors ai or player controlled? Why not use GameMode OnPostLogin to:
spawn → posses → set the needed tag
All in the GameMode class.

Event Possesed is called form the actor being possed. You can just access GameMode after the “Event Possed” and set it in this function too.

1 Like

Yes, i do that way. But I have the same problem… without a delay does not works.

am i doing something wrong?

this is what i wanted to do in my last try… but i have the same problem

Could it be that the problem is that onrep_teamTag failes early? That maybe the UI healthbar has not spawned yet and failes the cast? Try adding a break point on the on_rep_teamTag & stepping through with F10 and see if it get through the whole process (or even it it is called at all)

1 Like

Ok, I’ll try that and see what I can find. I’m actually using the health bar text to check if it works. The ultimate goal is to put the tag in the actor properties. The problem is that I can’t select an actor at runtime to see its properties because the editor slows down so much. It didn’t crash but almost.

4-actorTags

Ok, I’ll try to do the debug trace.
I will tell you about it.
Thank you very much!!

Yeah, something is wrong with the health bar… I don’t know what it is… when I put multiple players the health bar is visible from the other players… and it works when the player takes damage… then it doesn’t I understand why when debugging there is an invalid cast.

I’ll keep looking to see if I find what’s wrong.
Thank you very much.

Do a isValid test before the HealthBar.

The delay may be needed due to it being probably a widgetcomponent inside the actor that needs to be spawned & initialized. It might need some time for it to become valid.

1 Like

It is valid… But the invalid cast continues

Any way to make it wait?

I mean, the delay waits one second. But maybe the widget needs more or less time to be generated… if it needs more than a second then it’s going to fail anyway. That’s why I don’t like delays…

I don’t like this solution but for the moment it is the best I have found.

Got it working


2 Likes

Ok, I assume that it is not possible to do this without using delay or time.
I am very thankfull for your help.
Really very much appreciated.
:sparkling_heart:

There might be a way around the delay (probably more important on first spawn) maybe make the delay time a parameter and after first runctry setting itnto zero. I’ll let you know if i find a better way in the future

What do you think about this? It was an idea I had.
Maybe it’s too convoluted.
Maybe it can cause problems.

No I’m not sure about it

You don’t need to answer.
I’ve tested it.
It doesn’t work like I thought… It only checks the server side.
So the replicas also load the health bar with delay.
So it doesn’t solve any problem.
Your solution is the best in combination with the little macro I posted above.
:sparkling_heart: