Hello guys, how are u all doing?
I'm trying to change a KinematicsBody2D direction when it moves an X direction from it's initial position. I'm trying to use this code but it's not working and I don't have idea why.
var initialX = initial_position.x
var mxMove = max_move_distance
var posX = self.position.x
print("initialX ", initialX) #1318.27002
print("mxMOve ", mxMove) #400
print("posX ", posX) #It's updating fine
print("trigger ", initialX - mxMove) #918.27002
if posX == initialX - mxMove or posX == initialX + mxMove:
motion.x = speed * -1
motion.x = speed
It never triggers the if statment, even if the condition is true.
While writing this I though what may be the problem: the speed changes to speed * -1 for the one ms that the body is in that given position. Might be that?