I have developed a player controller in C++ with public variables used internally by the class. I then am creating blueprints parented from that class and attempting to set the blueprint variable in its blueprint script.
The first issue I’m having is oddities with debugging. The image below shows attempting to debug the OnLeftMouseNavigationY event, and the oddities are:
- At the breakpoint shown, the Input variable doesn’t display its value and the watch window indicates that the “Variable is optimized away and not available.”, even though it is read again below in the float Multiplier declaration line.
- I can’t set a breakpoint at the line above the current breakpoint line, where the MobileNavigationShiftMultiplier variable is set to 100.0f.
- The player controller blueprint that is parented off of this blueprint currently only prints the value of some of the variables, like MobileNavigationShiftMultiplier, and the values don’t match. I’ve been having a nightmare of a time trying to get my parented blueprint working, and have tracked it down to this problem. Any time I handle the mouse changing event in code I print the value of the shift multiplier variable as shown below. In the parented blueprint’s tick event I also read and print the shift multiplier value, should be the same exact value, and they don’t match.
- Similarly, when I add script in the blueprint to set the variable value (I’ve tried setting it in the constructor, in the BeginPlay event, and continuously in the tick event), and the value doesn’t get to the value read in C++ when I debug from mouse movements.
The C++ code printing the player control variable when the mouse moves (red):
The level blueprint tick script to print the variable value continuously (blue):
The print results:
I was suspecting that I was printing the variables from two different instances somehow, but when I set a breakpoint in the C++ constructor and BeginPlay event, they both only get called once when I play the game…