This is how I'd do it. I think your variable called `currentFrame` is actually the position in the X axis.
public float framesX = 6;
public float framesY = 6;
private float currentX = 0;
private float currentY = 0;
void Update () {
if (Input.GetButtonDown("Fire1")){
currentX += 1;
if (currentX == framesX) { // stepped off right side
currentX = 0;
currentY += 1;
if (currentY == framesY) { // stepped off top edge
currentY = 0;
}
}
}
// now do something with currentX and currentY
}
↧