Moderators: Despellanion, Dr. Best

Animation Scripts

Ultimga
Newbie
Ultimga
Newbie
Joined: 3:28 PM - Apr 18, 2013

6:47 PM - Jun 05, 2013 #1

Hello!

I'm here with some more scripts to make things easier for fellow U3D users, its a small and simple script that will help you
handel animations/play animations for your models!

You call this script in the step event of the object. Specify the start fram, end frame, animation speed,
and whether to play backwards then the object's model will animate if it has animation information in the model.

-Arguments-
Backwards? -> Should the animation play backwards? (True,false)
Speed -> The speed of the animation, 1 being speed that it was made to play at. You can't go lower then 1, but you can go higher.
StartFrame -> What frame does the animation start at?
EndFrame -> What frame does the animation end at?

The script is below the example usage, also attached the script if you can't/don't want to copy+paste.

-----Example-----

Code: Select all

if (cPlayer.moving = true)
{
       ANIM_BACKWARD = false;
       ANIM_SPEED = 1;
       FRAME_START = 0;
       FRAME_END = 30;
}
else
{
       ANIM_BACKWARD = false;
       ANIM_SPEED = 1;
       FRAME_START = 0;
       FRAME_END = 0;
}

UpdateAnimation(ANIM_BACKWARD,ANIM_SPEED,FRAME_START,FRAME_END)
-----SCRIPT-----

Code: Select all

//IMPORTANT: Make sure to initalize/decalare the variable _x_ !
//UpdateAnimation(Backwards?,Speed ,StartFrame ,EndFrame )
if (argument0 = false)
{
    _x_ += argument1 ; 
    frame = _x_ + argument2;
    
    if (frame > argument3)
    { 
        frame=argument2; 
        _x_ = 0; 
    };
}
else
{
    _x_ -= argument1 ; 
    frame = _x_ + argument3;
    
    if frame < argument2 
    { 
        frame = argument3; 
        _x_ = 0;
    };
};
UpdateAnimation.gml (505 Bytes)
UpdateAnimation.gml (505 Bytes)
Quote
Like
Share

RonBurgundy
Forum God
Joined: 9:49 PM - Sep 24, 2009

1:17 AM - Jun 06, 2013 #2

Umm
http://s9.zetaboards.com/Ultimate3D_com ... 603/1/#new

I would dismiss this as a cooincedence but our methods are all too similar.
Mine:
EDIT:
//Anim(Reverse?,AnimationSpeed,firstFrame,lastFrame,)
if argument0 = false
{
a+=argument1 ;
frame=a+argument2;
if frame > argument3
{
frame=argument2;
a=0;
}
}else{
a-=argument1 ;
frame=a+argument3;
if frame < argument2
{
frame=argument3;
a=0;
}
}


"Yours"
ards?,Speed ,StartFrame ,EndFrame )
if (argument0 = false)
{
_x_ += argument1 ;
frame = _x_ + argument2;

if (frame > argument3)
{
frame=argument2;
_x_ = 0;
};
}
else
{
_x_ -= argument1 ;
frame = _x_ + argument3;

if frame < argument2
{
frame = argument3;
_x_ = 0;
};
};

I hope I'am not being trolled here or something.


!!! DEFEND POP PUNK !!!
Quote
Like
Share

Ultimga
Newbie
Ultimga
Newbie
Joined: 3:28 PM - Apr 18, 2013

3:11 PM - Jun 06, 2013 #3

Holy crap
They are very similar, thats a huge cooincedence :blink:
I didn't know there was another animation script posted, or I wouldn't have put mine up..

Wow, can't believe they are so similar :think:
Quote
Like
Share

Despellanion
Forum God
Joined: 8:41 PM - Mar 26, 2006

9:19 PM - Jun 09, 2013 #4

Does it matter? It just generic coding.. I've done this method many times.
Quote
Like
Share

RonBurgundy
Forum God
Joined: 9:49 PM - Sep 24, 2009

3:19 AM - Jun 11, 2013 #5

It doesn't. Not trying to say its a big deal it just surprised me. I know its a simple method. If anything it's good to know some of us think alike. :D
!!! DEFEND POP PUNK !!!
Quote
Like
Share