Hello,
This is my first time working with Unity and I’m using it (and C#) to make a sprite-based 2D Fighter.
However, the problem I’m having with is the Frame Rate. I have been unable to make the game framerate-independent and I have been unable to maintain a frame rate of 60FPS.
My second problem is with the input. I am using the Street Fighter style of play and in order to perform a special you would have to input Down, Down-Right, Right, Punch. I have been testing that concept by writing a code that would accept any key as the right input. The problem with this is that it doesn’t accept any input after the first unless I hold the key down.
Can you guys help me find a solution to these problems?
Here’s the code for that particular script:
using UnityEngine;
using System.Collections;
public class SpecialMoveTest : MonoBehaviour {
public float inputTime = 0f;
public float inputLimit = 10f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
StartCoroutine(InputCheck());
}
IEnumerator InputCheck() {
if (Input.anyKeyDown) {
Debug.Log("Down");
while (inputTime < inputLimit) {
yield return new WaitForSeconds(1);
if (Input.anyKeyDown) {
Debug.Log("Down-Right");
while (inputTime < inputLimit) {
yield return new WaitForSeconds(1);
inputTime+= Time.deltaTime;
}
}
yield return new WaitForSeconds(1);
inputTime+= Time.deltaTime;
}
}
if ( inputTime >= inputLimit) {
Debug.Log("Input Finished");
inputTime = 0;
}
}
}
By the way, I only have two inputs in the above because I was testing the concept and if it succeeded I would have added more inputs.