Don’t know that you have to check the axis if you already have the Key ‘A’
I would just check after the key, if it’s already facing just do the animation, otherwise set the variable that you’re facing, change the scale, etc…
And do the same for the ‘D’ key?
if (Input.GetKey(KeyCode.D)) {
if (!facingRight) {
facingRight = true;
transform.localScale *= new Vector3(-1,1,1);
}
// etc , animation...
}
if (Input.GetKey(KeyCode.A)) {
if(facingRight) {
facingRight = false;
transform.localScale *= new Vector3(-1,1,1);
}
// etc , animation...
}
Like that?
technically, you wouldn’t even have to multiply here; you could simply set the correct one.
Hopefully I understood your question – just that moving one way wasn’t working… otherwise, oops… and what was the problem, if not this?
lol omg well scale it to the right amount, sorry… like if the normal scale is 20, then put that…
I mean you could use your code where you make a new variable and scale just the x portion also… doesn’t matter. both are okay.
I just want to get to the part to see if the flipping works
k… i notice a couple of things. Usually I associate right with positive scale. You have yours reversed … that isn’t necessarily a problem, could just be a choice, I guess.
In the ‘A’ key , you wrote if Facing Right, set facing Right = true - that should be set to false.
And this part, I don’t know, but you set animstate to 4 on both keys, but in your first post, you had 3 & 4.
Ok that part is working. Thank you so much. Do you think you could help me fix another small glitch with it though? Say I hold W and then a few seconds I hold D. It shows my walk up animation, instead of switch to the walk right animation.
Cool, glad that’s working… Um… So, showing walk up but not turning, you mean?
What would you want to see if both were held down? W or D? I’m sure you want it to turn regardless, but is there a preference for the other two ?
Let’s say: W,A,S,D = 0,1,2,3
KeyDown W … list add 0 … starting up animation…
KeyDown D … list add 3 … starting right animation…
KeyUp D … remove 3 … check if it was list Count - 1 … if it was play List.Count - 2 (if Count - 2 >= 0)
Otherwise, say it was Down: W, D, A and D was up… just remove D… but since it wasn’t the end, A is still the “last” ?