I am a beginner at unity and am trying to make a 2D sword fighting game.I have ran into difficulties trying to make my character do an attack. My character plays a crouching or dodging animation when I click Z. I would like him to also do an attack while he is crouching when i click S. This is what I tried so far, but it is not working:
using UnityEngine;
using System.Collections;
public class CharacterController : MonoBehaviour {
bool pressS = false;
bool down = false;
void Update ()
{
if (Input.GetKeyDown (KeyCode.Z)) {
anim.Play ("DownDodge 2");
}
if (Input.GetKey (KeyCode.Z)) {
down = true;
}
if (Input.GetKeyUp (KeyCode.Z)) {
down = false;
}
if (Input.GetKey (KeyCode.S)) {
pressS = true;
}
if (Input.GetKeyUp (KeyCode.S)) {
pressS = false;
}
if (down = false && (pressS = true)) {
anim.Play ("DownSlash");
}
}