===
Hello!
I'm attempting to tinker with an existing freebie eye blink script to fit it to my own uses. However, the problem I'm running into is that frames 2-4 stretch out slightly during the animation. I've checked the texture itself and all sets of eyes match to each other so the issue doesn't seem to lie there.
Unfortunately, I'm hopeless when it comes to scripting aside from small changes here and there. Looking at the script I am unable to determine what could be happening that stretches those frames.
Any advice would be greatly appreciated. I can also offer the sample eye texture to anyone who wants to see the issue 'live' in-world. Thank you~!
The script I'm working with follows:
CODE
// This blink script uses a single texture with the frames set up as follows within the image.
//
// +-----+-----+
// | 1 | 2 |
// +-----+-----+
// | 3 | 4 |
// +-----+-----+
// The minimum time between blinks
float minBlinkTime = 0.5; // in seconds
// The Maximum time between blinks
float maxBlinkTime = 12.0; // in seconds
// The animation frame speed
float animationSpeed = 7; // in fps
// number of frames in the animation
integer numberFrames = 4;
// temporary variable
float waitTime;
// Returns a reandom number between min and max
float randBetween(float min, float max)
{
return llFrand(max - min) + min;
}
default
{
// Main part of the program
state_entry()
{
// Sets the size and position of the default frame
llOffsetTexture(-0.25,0.25,ALL_SIDES);
llScaleTexture(0.7,0.5,ALL_SIDES);
// Intialize time even
llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime));
waitTime = (numberFrames * 2) / animationSpeed;
}
// Timer event
timer()
{
// Temporarily turn off the timer event
llSetTimerEvent(0.0);
// Animate the eyes onces.
llSetTextureAnim(ANIM_ON|PING_PONG,ALL_SIDES,2,2,1,4,animationSpeed);
// Wait for the eyes to finish animating
llSleep(waitTime);
// Turn off animation
llSetTextureAnim(FALSE,ALL_SIDES,2,2,1,4,animationSpeed);
// Reset Timer for next event
llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime));
}
}