- Home /
Changing players animation depending on movement (left - right ) lagging problem ?
if (Player_1.transform.position.x < Mouse_Position_Animation_State.x - 0.2f) { if (string.Equals (Player_1_Skeleton_Animation.AnimationName, Run_Left_Animation) == false) { Player_1_Skeleton_Animation.state.SetAnimation (0, Run_Left_Animation, true); %|2044065025_3|% %|1021557221_4|% } else if (Player_1.transform.position.x > Mouse_Position_Animation_State.x + 0.2f) { if (string.Equals (Player_1_Skeleton_Animation.AnimationName, Run_Right_Animation) == false) { Player_1_Skeleton_Animation.state.SetAnimation (0, Run_Right_Animation, true); %|379788277_7|% %|545407355_8|% } else { %|1994289157_9|% %|942211266_10|% %|-1141119596_11|% %|1601939522_12|% %|76521841_13|% } Mouse_Position_Animation_State.x = Player_1.transform.position.x;
Hi!
In order to change animations i have Mouse_Position_Animation_State.x that is players position in the last frame of Update, and depending on that i change animation name... so if (Player_1.transform.position.x < Mouse_Position_Animation_State.x - 0.2f) it will change animation but a little bit delayed, but at some point it will look like player is lagging, and if (Player_1.transform.position.x < Mouse_Position_Animation_State.x ) it will change animation instantly and again the same thing...
Is there anyone who can help me with this?
Thanks! Danijel.
And i dont know why this code is not organized sory about that!!
Your answer