"CompareInt" not working every time

Hi guys,

I’m trying to make a little random movement for a boss in my shmup game. Movement is simple: flying from left to right and back. I thought that a random integer in range and CompareInt node would do the trick. The thing is, sometimes (after animation that he’s flying down from the sky) my boss is flying left, sometimes he’s going right, and sometimes he’s not moving at any direction, he is just standing still. Do anyone know what is wrong with my blueprint? It looks quite simple. Or maybe there is other way to do that kind of random movement? Thanks in advance

It’s a classic random issue everyone runs into. Every time you access the random node it generates a random result - the node does not store the previous result; access it twice, get 2 (potentially different) results. First *Compare *can get a 1, and second one can get a 0 - meaning nothing will happen.

Before you Compare, store the result in a *int *variable, then use that for comparison.

This explains everything. Thank you very much!