Variable won't change even though its public

Hi there, this is probably something simple and stupid but I have been banging my head against the wall for the last two days. I am currently making a 2d platformer.
What I have done is created a public/editable variable in a class blueprint. This variable is set to change in the level blueprint yet it doesn’t, it just remains NULL.
The variable is to check which checkpoint in the game has been pressed to decide where the player should respawn at, but because it remains NULL, the player always
spawns at the start of the level. I have tested it by changing the default value and this actually works but the variable will not change through the blueprints by itself
when the player triggers the box.
What am I doing wrong?


Check that your cast is not failing. If it is always failing, it will never change the variable value.

Yeah it seems to stream into the cast but not out :frowning: Any ideas why that sort of thing would happen?



If the Other Actor is not an BP_Spike then casting to BP_Spike will fail.

Sorted it now. Thanks for the help friend.

You should post what you did to fix it, so that others in the future that have a similar problem can see how you solved yours. That solution my help them as well.

1 Like

Yeah it’s difficult because my problem was so vague I guess. I ended up changing which blueprint decided where the player is spawned once they die. Originally I had the teleports in the spike class blueprint, but this was causing problems when it came to the the character colliding with it in the level blueprint. So I changed the character blueprint to decide where the player is ported instead.

In the image I attached, the custom event is triggered when the spike is hit (inside spike class blueprint) Input is then disabled and a final check to make sure the player is dead, is initialised. Once true, the blueprint checks which checkpoint was the last to be triggered (in the level blueprint) and then teleports them accordingly through an enum check.