You must have a trigger that sets the WalkingOnBeam bool to true when the character steps on the beam. Make it two triggers on each end of the plank, and if entered from end, reverse the axis value: