- Home /
Dynamically setting sprite frames through code - Unity 2D 4.3
Hey all - I'm rebuilding my game which bears some similarities in form to Crack Dot Com's Abuse , in that I am trying to manually set the animation frame of the Player Torso based on the position of the mouse cursor.
After some preliminary research, it seems that an option I have is to simply manually set the "time" of the animation through code, as in:
animation["player_torso_pistol_aim"].time = frame;
Unfortunately, it doesn't seem that this works - I set "frame" to be a public variable, and during runtime I manually change its value via the inspector, but the actual frame of the torso doesn't respond.
My setup has:
A Player_Torso Animator object that has one animation associated with it: player_torso_pistol_aim, with 16 frames, each assigned to a different time: 0:00, 0:01, 0:02, etc.
With the Animator window open, I have set the "speed" of player_torso_pistol_aim to 0.
player_torso_pistol_aim is set to NOT loop, all other variables default.
Is there a setting that I'm overlooking, or am I going about this the completely wrong way?