Situation: Vehicle has stats like gas level, damage level, and so on, but all set to zero. Driver has the stats of those values that I want to pass to vehicle when driver is selected through menu. Then on game start the vehicle stats are updated from the driver, then displayed on the hud. I have tried many ways to pass the value to the vehicle but none of them are working for some reason. Casting, BP variable get and set. I have everything else figure it out, I just need some way to pass the value to the vehicles stats. My setup: BP for all the drivers in one BP using functions for every driver that have variable outputs with the values. Then calling the functions when driver is picked from the menu, then passing to vehicle BP to set the values in the vehicle. I’ve tried cast this same way. If someone can post pictures of what I’m trying to accomplish that would be great. I’m a little confused about which values to set on editable and such.
You can use a Blueprint Interface to do this. Also, I believe in 4.6 that a variable must be public and editable to be read by other classes (maybe).
I’m using 4.5
Then you don’t need to make them editable to pass them between classes afaik. Just go on youtube and look up a tutorial on Blueprint Interfaces, they’ll be useful for what you’re doing.
Im looking and reading doc on interfaces but still not getting it for my situation. Its more for having multiple objects using one blueprint but I’m looking for the other way around. 1 vehicle with the drivers that all have their own BP or values. Vehicle has same variables as drivers but when driver is picked it then changes the values of those variables in the vehicle.
i don’t know how much drivers you have but at least, if you set a var “selected” in your driver and create in your truck a function “drivermodifs” with get all actor driver / loop with break / cast to driver / branch (selected true) get values / set values output on return node / break / completed to return node and use this function to modify your values in your set truck values, it would be ok.
I think I know what your getting at. Any way you can post a pic of this.Confused about where im making this function. Im a noob but learning vary fast. I have tried making a function on the driver BP with driver variables going to output on that return. Then calling function in truck BP and hooking up the outputs to a set node in the truck for that variable.
In my idea function was in truck, but you can set it in driver too and drag it from "get all / loop / cast " in your truck too. I added get all actors with interface if you use interface, it’ll do the same.
What exactly is the break doing when your looping back around from branch? You can get the same result without the branch and break?
Yes, break just stop your loop to save ressources if for example you have an array of a hundred of items but it saves too if you have a dozen. And the exit of the function is on completed not in a loop exec which avoid issues.
Each time we can use it, we would, to save ressources (as using a reference instead of get all actors when we can set it, or get / find instead of loop when we know that the array have only one item for example).
And using the loop body output to continue your global function is not good because your array will go to completed once function is done, which can do troubles too.