Hi
Im trying to get my 3rd person character to play its walk cycle on more keys than forwards(namely backwards and sideways as well)
He has a rigidbodyfps controller on him to move him in 3d space, and a mouselook to turn him and ideally Id like a “GetKeyDown(“AnyKey”)” type thing to work. Heres my current working script
private var waswPressed = false;
function Update()
{
if (Input.GetKey("w")) {
waswPressed = true;
print("animating");
animation.Stop("Idle");
animation.Play("Walk");
}
else
{ waswPressed = false;
print("HanginOut");
animation.Play("Idle");
animation.Stop("Walk");
}
}
I cannot find anything in the docs or examples to go further on this. I need to use a rigidbody fps controller in order to detect a collision, so I dont really want to use a character controller. Ive looked at the “GetAxis” approach, and it look like you can use horizontal, or vertical, but not both. Its either a walk or idle animation, so getanykey would be great but It never compliles without errors… Any leads anyone? Thanks
AC
Thanks heaps Yoggy! that worked a charm-how did you learn all this stuff?
things like the != 0 || part of your statement and bits like “” and “==”
intrigue me…
thanks man, that fixes the last bug in my 3du entry-though its too late for the gig, it satisys me greatly to finish this…Happy Summer Solstice-though its probably winter solstice where you are…
Aaron
When reading them aloud replace “==” with “is equal to”, “!=” with “is not equal to”, “||” with “or” and “” becomes “and”.
So in English, “if(Input.GetAxis(“Horizontal”) != 0 || Input.GetAxis(“Vertical”) != 0)” roughly translates to “If the Horizontal input axis is not equal to zero or the vertical input axis is not equal to zero.”
I know it has all of those (they are used to scriptify layer masks), except for XOR I’m not sure about - I think the operator for that is traditionally ^ but don’t quote me on that.