I’m trying to port a script over to ios from the webplayer version and I’m having an issue with my main player’s animation. It’s only displaying it’s right idle animation from the sprite sheet regardless of its direction of the idle as well as it’s action (walk, jump, etc.) Here’s how I’m calling it in the script:
function PlayMarioAnim()
{
var aniPlay = GetComponent (aniSprite); //set aniPlay to aniSprte.js
print(MarioMode);
switch(MarioMode)
{
case MarioMode.idleRight:
aniPlay.aniSprite (16,16,0,1,16,12);
break;
case MarioMode.idleLeft:
aniPlay.aniSprite (16,16,0,0,16,12);
break;
case MarioMode.walkRight:
aniPlay.aniSprite (16,16,0,2,10,15);
//print("Walk Right Animation");
break;
case MarioMode.walkLeft:
aniPlay.aniSprite (16,16,0,3,10,15);
break;
case MarioMode.turboRight:
aniPlay.aniSprite (16,16,0,4,16,24);
break;
case MarioMode.turboLeft:
aniPlay.aniSprite (16,16,0,5,16,24);
break;
case MarioMode.crouchRight:
aniPlay.aniSprite (16,16,0,8,16,24);
break;
case MarioMode.crouchLeft:
aniPlay.aniSprite (16,16,0,9,16,24);
break;
case MarioMode.walkJumpRight:
aniPlay.aniSprite (16,16,11,2,4,12);
break;
case MarioMode.walkJumpLeft:
aniPlay.aniSprite (16,16,11,3,4,12);
break;
case MarioMode.runJumpRight:
aniPlay.aniSprite (16,16,11,2,4,12);
break;
case MarioMode.runJumpLeft:
aniPlay.aniSprite (16,16,11,3,4,12);
break;
case MarioMode.crouchJumpRight:
aniPlay.aniSprite (16,16,12,10,4,12);
break;
case MarioMode.crouchJumpLeft:
aniPlay.aniSprite (16,16,12,11,4,12);
break;
}
}
And here’s what my aniSprite script looks like:
function aniSprite (columnSize : float, rowSize : float, colFrameStart : float, rowFrameStart : float, totalFrames : int, framesPerSecond : int)// function for animating sprites
{
var index : int = Time.time * framesPerSecond; // time control fps
index = index % totalFrames; // modulate to total number of frames
var size = Vector2 ( 1.0 / columnSize, 1.0 / rowSize); // scale for column and row size
var u = index % columnSize; // u gets current x coordinate from column size
var v = 0 / columnSize; // v gets current y coordinate by dividing by column size
var offset = Vector2 ((u + colFrameStart) * size.x,(1.0 - size.y) - (v + rowFrameStart) * size.y); // offset equals column and row
renderer.material.mainTextureOffset = offset; // texture offset for diffuse map
renderer.material.mainTextureScale = size; // texture scale for diffuse map
renderer.material.SetTextureOffset ("_BumpMap", offset); // texture offset for bump (normal map)
renderer.material.SetTextureScale ("_BumpMap", size); // texture scale for bump (normal map)
}
Any help would be greatly appreciated, I’m sure I’m just missing something but I can’t seem to figure out what it is.