- Home /
flipping animation (I know this is asked alot)
Yes, I know this has been asked a lot. Again, I'm a Unity noob, and I've looked this up before but nothing I find has really helped me out. I could easily flip animations by making a separate animation where I flip her and save it as "walkLeft" or something, but that would take up a lot of space in both storage and animator. `
if (Input.GetKeyDown(KeyCode.D))
{
anim.SetBool("thatway", true);
anim.SetBool("thisway", false);
transform.localEulerAngles = new Vector3(0, 180, 0);
}
if (Input.GetKeyDown(KeyCode.A))
{
anim.SetBool("thatway", false);
anim.SetBool("thisway", true);
}
here's some code I tried, and it sort of worked but she'd only change direction once, and I don't really know how to fix this, or why it's happening. Help would be really appreciated! Again sorry for being such a noob lol :)
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.D))
{
anim.SetBool("thatway", true);
anim.SetBool("thisway", false);
transform.localEulerAngles = new Vector3(0, 180, 0);
}
here's the rest of the code..Idk it's not working sorry lol
I notice you only set the transform's direction when D is pressed. Why don't you do the same/opposite, when A is pressed? Also, I would suggest you use a single bool, since one can only go left OR right, not both. Simply choose true=left, false=right. If necessary you COULD use another bool called say... "noTurn", to indicate whether to go straight or to turn.
@Glurth Hey, thanks for the reply! The reason I didn't transform for both D and A is because she starts out facing right and I don't want the A button to turn her left when she's already facing right. Plus I think there's more issues than just that part. Other than the camera being a child, and switching with the player (lol oops), do you think you could write out an example of your idea? Id be really grateful (again, sorry for being such a noob)