# Character look at mouse position
if playerTarget == null:
rayHit.y = player.translation.y
# Character look at target
mouseTarget = playerTarget.transform.origin
mouseTarget.y += 1.5
This is supposed to check if the mouse is pointed at an enemy. If so, player looks at enemy, if not, it just looks at the mouse position. Problem is every now and then, when testing the game, i get a null instance error after killing an enemy saying that playerTarget cant be found because its a null. Any ways to fix this?