Why is my cast to blueprint failing?

Hi, I’m new to UE4 so I’m not sure if what i am doing is correct. I have created a desert style map with a day/night cycle. I wish to make it so that it is too cold to stay outside in the middle of the night and the player must be near fire.

I am using a blueprint ‘simple sky’ to control the ‘sky spheres’ sun position. i am then casting from ‘simple sky’ to the ‘sky sphere’ to get the sun height value. when the height value is below -0.6 a new variable ‘temp cold’ starts to count down from 30. ( works fine)

I have then set up a box trigger around the fire. when the player overlaps the box trigger i want to cast to the ‘simple sky’ (from level blueprint) and set the ‘temp cold’ back to 30 but the cast is failing. i think it might be the casts object input causing the problem but I’m not sure what i need to connect it to or even if that is the problem.

Any help would be greatly appreciated!!

Thanks!

Hi Soundguy,

Your cast is failing because currently you are not checking any variable to cast. It is reading a NULL value, so effectively your cast reads:

“Cast NULL to Simple_Sky”, which will always fail because there is nothing for it to test. Add in a reference to your simple_sky to the input pin of your cast node.

Problem solved! Thanks for your help and such a quick response!