Hello! I’m very new to Unreal Engine with only a little bit of knowledge. And I may have bit off more than I could chew. Essentially the issue is, from a player controller, which runs everything, I need to access an udefined variable. I came from Roblox Studio, which had a nifty function called waitforchild if anyone is familiar with that. It allows you to wait for an undefined asset to load. In my case that “asset” is a variable, and several static meshes of my character.
More detailed description:
Gamemode blueprint loads the character. Character is possessed. Player controller can’t access the variables or the hull, turret, and cannon, in my tank. My conclusion is that the issue is because the player controller doesn’t yet know what I’m going to spawn, and therefore won’t let me rotate the tank even once it spawns.
Things I’ve tried:
I have tried to set up all the variables in my player controller for each individual tank, but once it spawns, I still can’t access the static mesh components.
I’ve tried to spawn the tank from the player controller. But I still run into the issue that if I swap tanks, it won’t know what the components are.
I’d do it the other way around; rather than having the player wait for the tank to spawn, I’d have the tank send a message to the player when it spawns. So the flow would be:
Player spawns. It has a (null) reference to its tank.
The player’s tank spawns. It gets a reference to the player and then calls a function on the player to essentially say “This tank is yours”
The player now has a reference to the tank, and can do whatever additional setup it needed to do.
This does mean you’d have to have null checks practically everywhere, but you generally need those for this kind of dynamic spawning anyway.
The only issue is that the Gamemode base spawns the character, I don’t know how to transmit information across two scripts. Especially Gamemode base and the player controller. I’m not entirely sure how they replicate across clients.
Hm, how would you go about doing this kind of thing? I’m extremely new with barely any experience, I’m just trying to come up with solutions since no one has tutorials about this.
So have you ever played a game like World of Tanks or War Thunder? Oh boy, can’t reply anymore. First day maximum I guess.
Edit 1:
So you can pick out different tanks. And then each has unique stats. Such as rotating speed, forward and backward speed. Health, armor, etc.
I want to be able to pick out a different tank currently just in the editor but something simple, that way I can make tank selecting and tank blueprint creation easier.
Edit 2:
I have to go for a bit, but I’ll be back on, rest assured I’ll try to implement some of your ideas. Thanks again @ClockworkOcean.