Newbie Asks: Anyway to do Animation SUBRange Looping?

Non-platform specific questions.

Newbie Asks: Anyway to do Animation SUBRange Looping?

Postby ggesterGamePro99 » Sun Apr 22, 2012 11:51 pm

We know animations loop automaticaly.

but what if we want to do that but sometimes we want to tell the program to loop within some range of that animation

For example if the animation image sequence is 50 images..the normal loop is 0-49
But what if i want to do 15 to 30.

But i mean, without loading any extra or different animation image sequence.
I just want to have the 50 images but loop on random ranges and sometimes the whole range.

for example sometimes 0-50, sometimes 15-30 sometimes 8-23 or whatever.

PS. When i load my animations to loop, they're not actually looped animations.
I loop them using the Script editor.
--> Once reach end change the animation direction tO BACKWARDS.. Once reach begining(animpos = 0), then change animation direction to FORWARD. That works

But i want to do this on a SUBRANGE
and so far i don't quite know how
because the ANIMPOS variable still goes from 0 to the end.
so is there a way to loop within SUBRANGES of an image series animation?
Last edited by ggesterGamePro99 on Sun Apr 22, 2012 11:54 pm, edited 1 time in total.
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: Newbie Asks: Anyway to do Animation SUBRange Looping?

Postby skydereign » Sun Apr 22, 2012 11:53 pm

If you want to do this without using sequences, then you have to use code. You can change what the actor's current frame is by changing its animpos variable. So you would need two variables, the start frame and the end frame, and put something in the actor's draw event to check if animpos is greater than the end frame, if so set it back to start frame.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Newbie Asks: Anyway to do Animation SUBRange Looping?

Postby ggesterGamePro99 » Sun Apr 22, 2012 11:57 pm

skydereign wrote:If you want to do this without using sequences, then you have to use code. You can change what the actor's current frame is by changing its animpos variable. So you would need two variables, the start frame and the end frame, and put something in the actor's draw event to check if animpos is greater than the end frame, if so set it back to start frame.


Thanks.. so far i haven't found out how
because if i set a STARTFRAME and ENDFRAME,,,,how do i set ANIMPOS to look at STARTFRAME as it's initial frame, rather than think that it's initial frame is 0.
Because 0 as an initial frame would be the original animation's startframe.


So at one time i tried

if( animpos == STARTFRAME)
ChangeDirection to FORWARD

but apparently that didn't work.
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: Newbie Asks: Anyway to do Animation SUBRange Looping?

Postby ggesterGamePro99 » Mon Apr 23, 2012 12:10 am

This is what i have so far.
It seems to work alittle for the first few times, but then after that, it never again pics a subrange and it never again loops.
It's weird, it does pick a subrange for like the first 3 loops that happen...then after that it never loops again:
(PS..SUBRangeENDFrm and SUBRangeSTARTFrm are GLOBAL variables i made)


if( animpos = (nframes -1) - SUBRangeENDFrm){
ChangeAnimationDirection( "event actor", BACKWARD);

SUBRangeSTARTFrm = rand(nframes -1 ) + 0;
SUBRangeENDFrm = rand(nframes - 1 ) + SUBRangeSTARTFrm;
}
else if( animpos == SUBRangeSTARTFrm){
ChangeAnimationDirection("event actor", FORWARD);
}
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: Newbie Asks: Anyway to do Animation SUBRange Looping?

Postby ggesterGamePro99 » Mon Apr 23, 2012 1:09 am

Ok I fixed the subrange looping.
well this is my solution. I just changed it around because it wasn't ever going into the if( ANIMPOS = SUBRANGESTART)
since both SUBRANGESTART and END are both set to zero in the default


if( animpos = SUBrangeSTARTFrame){
int random = rand(20 ) + 1;
Change animDirection to FORWARD;

if( rand > 10 ){ //PICK SUBRANGE
SUBRangeSTARTFrame = rand(nframes - 1) + 0;
SUBRangeENDFramae = rand(nframes - 1 ) + SUBRangeSTARTFrame;
}
else { //PICK ORIGINAL ANIMATION range.
SUBRangeSTARTFrame = 0;
SUBRangeENDFrame = nframe - 1;
}

}
else if( animpos == SUBRangeENDFrame ){
Change Animation Direction to BACKWARD

}
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: Newbie Asks: Anyway to do Animation SUBRange Looping?

Postby skydereign » Mon Apr 23, 2012 3:26 am

If that is actually the code you are using, than you are using if statements incorrectly in some cases.
Code: Select all
int var = 0;

if(var=5) // this is always true
{
    // var has been set to 5 by the if statement
}

Code: Select all
int var = 0;

if(var==5) // this triggers only when var is equal to 5 (note it does not change the value of var)
{
    //
}


As for having to set the ranges, you can do that in a create actor script. Then change it as you please. But the code that I was mentioning was just this.
Code: Select all
if(animpos>=end)
{
    animpos=start;
}

And of course you have to set end and start, but that is pretty straightforward.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest