I’m trying to get a boolean value to be changed (and read) from a blueprint scrip, see below.
I have for testing assigned recording to be set to true when C is pressed in my pawn blueprint as per below:
But whatever I try never seems to work.
I have gone through several YouTube videos as guides but its left me going around in circles.
The cast always fails, I’ve checked the switch record variable in my pawn blueprint but can’t figure why I can’t get it to work.
Could anyone point me in the right direction?
You are casting your pawn into a switch, which it is not, so the cast fails. If the switch is an actor in the world you should have a reference to it somehow, and store it in a variable in the MySwitch type (or just use it).
You should first get the reference to the switch actor somehow.
After doing that you can just use it.
Thanks, I’ll give this a try now!
The switch isnt an actor in the world, I’m guessing then the solution you provided will have to be tweaked?
I do have other variables in my pawn class which are being set in different locations which is why I can’t understand why the different methods I have tried have failed.
Basically I have a section in my pawn blueprint that records data, I want to put a boolean just before it to switch between recording & not recording. I want certain levels in my system to allow recording and one or two to not allow recording. So this record switch would be set in the level blueprint and read from the pawn blueprint. I’m only setting it here to test.
I don’t think actors in the level can read from the level blueprint, when I’ve tried it it resulted in a big error, but the level blueprint can set a variable on a pawn, so I would do it like this
Of course if you want to set a boolean for recording you can do so after the first branch.
On levels that cannot record, just do not set CanRecord at all as the default is false, or maybe if the minority are levels that cannot record, set CanRecord’s default to true and set it to false only on those maps.
Many many thanks!
Things are much more easier in python/C++! I’ll try it now and let you know how it goes.