# Variable won't change even though its public

**URL:** <https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [August 30, 2015, 4:29pm UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198 "2015-08-30T16:29:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_96297899](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_96297899](https://forums.unrealengine.com/u/anonymous_user_96297899)\
**Post date:** [August 30, 2015, 4:29pm UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198/1 "2015-08-30T16:29:48Z")

</div>

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?

Thanks!

---

<div class="post-metadata">

**Author:** ![DevilsD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/devilsd/32/890854_2.png) [@DevilsD](https://forums.unrealengine.com/u/DevilsD)\
**Post date:** [August 31, 2015, 6:45am UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198/2 "2015-08-31T06:45:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_96297899](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_96297899](https://forums.unrealengine.com/u/anonymous_user_96297899)\
**Post date:** [August 31, 2015, 9:07am UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198/3 "2015-08-31T09:07:39Z")

</div>

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

Cheers

---

<div class="post-metadata">

**Author:** ![DevilsD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/devilsd/32/890854_2.png) [@DevilsD](https://forums.unrealengine.com/u/DevilsD)\
**Post date:** [August 31, 2015, 9:58am UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198/4 "2015-08-31T09:58:10Z")

</div>

If the Other Actor is not an BP\_Spike then casting to BP\_Spike will fail.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_96297899](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_96297899](https://forums.unrealengine.com/u/anonymous_user_96297899)\
**Post date:** [August 31, 2015, 2:16pm UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198/5 "2015-08-31T14:16:54Z")

</div>

Sorted it now. Thanks for the help friend.

---

<div class="post-metadata">

**Author:** ![DevilsD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/devilsd/32/890854_2.png) [@DevilsD](https://forums.unrealengine.com/u/DevilsD)\
**Post date:** [September 1, 2015, 6:43am UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198/6 "2015-09-01T06:43:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_96297899](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_96297899](https://forums.unrealengine.com/u/anonymous_user_96297899)\
**Post date:** [September 1, 2015, 8:45am UTC](https://forums.unrealengine.com/t/variable-wont-change-even-though-its-public/40198/7 "2015-09-01T08:45:54Z")

</div>

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.
