Trying to track and store an old value of a variable

I’m trying to track two variables for my players mouse location.

The first is its current location, and the second is its previous location.

I’m then trying to find the difference between the two and apply it to a game mechanic.

Currently i’m trying to use a sequence node connected to an event tick to get the current mouse location and use that value as the past location, then find the difference in the two values. However this isn’t working as the value is always zero. Rather than the desired value being positive or negative when my mouse is moved, and zero when its not being moved.

From what i understand, Sequence 0 is updating CurserLocationX then setting OldCursorLocationX with its new value, Then Sequence 1 is updating CursorLocationX again then finding the difference between the two variables and setting that value as CursorTickDiff, then repeating Sequence 0.

The variable for the mouses location is working just fine. Anyone know what i’m doing wrong? Does a sequence node not work as i think it does?

Hey there, it makes sense that is always zero, because you set the old to the value of the current before you do the comparison, so they will always be the same. Try inverting the order, first do the diff, then do the set old. I’m assuming before that sequence node you set the value of the current with the latest value.

ok, that worked. Sequences make more sense now, i figured the next sequence would play on the next event tick but it doesn’t.

Thanks :slight_smile:

Good to know :slight_smile: