Hey all! I have a little problem with my script. I know exactly where it is so I won’t paste my whole script in here. Basically in my game I want to only have my character move in 8 directions using wasd. I’m trying to do this with if functions for every direction. My problem is that I cannot just do a simple and for two keys being pressed and I’m not sure of any other way to do it. Any help is appreciated.
An example of one of these in action:
if (Input.GetKey (KeyCode.W || KeyCode.A)) {
transform.rotation = Quaternion.Euler (theRigidbody.rotation.y, 315, theRigidbody.rotation.z);
theRigidbody.velocity = new Vector3 (-moveSpeed, 0, moveSpeed);
theAnimator.SetBool (“Idle”, false);
theAnimator.SetBool (“Walking”, true);
}
This way of doing things gives me 16 errors. I’m pretty sure it would all be fixed just by changing this one thing. An example of an error: Assets/PlayerController.cs(26,43): error CS0019: Operator ||' cannot be applied to operands of type
UnityEngine.KeyCode’ and `UnityEngine.KeyCode’
Thanks again if you can come up with a different way to do things.