- Home /
How do I compare an object's current position with a previous position?
Hi there, I've been working on creating a fighting game combat system, in which you knock your opponent backward when you hit them, but if the opponent's x position doesn't change after the knockback (i.e. if they're in the corner) then the attacker will be pushed back.
I've tried using the command "cornerPosCheck = otherPlayer.position.x;" to store the x position of the opponent in a float before they receive knockback, but after I apply the knockback, and see if the two variables have a difference of 0, through "cornerPosCheck - otherPlayer.position.x == 0", the attacker is pushed back regardless of enemy position.
I'm wondering if there is some issue with what I am doing, like if I'm comparing memory location instead of position, or if there's some better way of doing this.
Thank you.
Your answer

Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
Compare Position of two gameobjects and if true, do nothing, help me please! 1 Answer
C# store compare start position and actual position 1 Answer
making position checker - is area empty or not (with trigger)? 2 Answers
How to change animation in the code? 1 Answer