Issue with respawning player
Hi so I recently put in a re-spawn/checkpoint system and its breaking something in my blueprint. So I have an event tick ruining in a different script that checks the distance to the player
It is not game breaking but it does annoy me, does anyone have an idea of how i could fix this issue?
asked Dec 12 '16 at 11:10 PM in Blueprint Scripting
Yes this happens because when you destroy the player character the Get Player Character node will return a null object (since the player doesn't exists at that moment) and thus the erros.
What you can do to solve this is to add a check to see if the player exists before trying to read its distance property. You do that with an Is Valid macro node you pass the return pin from the Get Player Character node to the Is Valid node and then you just continue with your stuff in the Is Valid execution line.
Note that this check can be added inside your Check Dist to Player function but you would need to handle the case where the playing doesn't exist by returning something like -1 (Since there aren't negative distances). Or you could do the check before calling your function, if the object is valid, call your function if it isn't then don't call it.
answered Dec 12 '16 at 11:32 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here