Expression to detect horizontal axis vector
Hey guys. I'm trying to make an object that is gonna horizontally flip itself when it changes his x axis vector.
It basically works, but the problem here that when object isn't moving anywhere or hit keyframe, velocity goes to 0 and because there is no statements that are going to flip object scale, so it goes to the start scale of [100, 100]. Numbers on screenshot is velocity - when it's negative - scale flips from [100, 100] to [-100, 100]
There is expression that I've been using;
if(transform.position.velocity[0]>0){
[-100, 100]
}else{
[100,100]
}
What I want to do is the object will remember his last scale number. So if we go from left to right, animation ends - object gonna safe his last scale. What do you think?



