ANM_CYCLE - workshop 21 - problem

Posted By: Sonne

ANM_CYCLE - workshop 21 - problem - 03/15/09 13:17

Greetings,

I've gone through the workshop tutorial pretty easily and didn't notice this until I came across the problem on my project I am making from scratch. What I am trying to do is if no buttons are pressed my model does a 'stand' animation for .. well .. forever. However after some time the model stops cycling through 'stand' and begins cycling through all the animations. So I first checked my code and compared it to the examples on the forums, wiki, manual, workshop and found no differences. Then I loaded up workshop 21 again and saw the exact same behavior. Regardless of the animation_percentage multiplier, the model goes spaztastic around 45 seconds (based on total_secs)

Code:
action walking_guard()
{ 
	while (1) 
	{ 
		ent_animate(my,"walk",walk_percentage, ANM_CYCLE); // "walk" animation loop
		walk_percentage += 3 * time_step; // 3 = animation speed for "walk"
		wait (1); 
	} 
} 



As shown in the screen shot the model is in frame 'attack' but based on the code it shouldn't get there. Wondering if anyone else has encountered this and how to fix, resolve, work-around it.

I am using the trial version; SED 7.11.1 MED 6.902 WED 7.7 v6.89.

~ Thanks in advance
Posted By: EvilSOB

Re: ANM_CYCLE - workshop 21 - problem - 03/15/09 14:27

Add this line before the wait and see if it helps.
walk_percentage = cycle(walk_percentage, 0, 100);

PS: Welcome aboard.

Posted By: Sonne

Re: ANM_CYCLE - workshop 21 - problem - 03/15/09 15:06

Originally Posted By: EvilSOB
Add this line before the wait and see if it helps.
walk_percentage = cycle(walk_percentage, 0, 100);


The walk_percentage (animation_percentage) value was something I also considered. When I watched that it would continually climb well past 100 but the animation still cycled through normally for the first 45 seconds normally. I think I could achieve the same thing by using:

Code:
walk_percentage %= 100;


I did try it though and same result. Although the percentage working normally with a higher value is explained by George Pirvu in his workshop:

Quote:
"animation_mode" tells the engine to play the animation in a cyclic loop (animation_mode == ANM_CYCLE) or to play a one-shot animation (animation_mode = 0). If the animation_percentage value grows over 100 in a cyclic animation, it will just continue with the first frame again; on the other hand, a one-shot animation will stop at the last frame.


Thus it is problematic, because I am not sure what is causing the problem. Is it safe to assume other people have no problem running one continuous animation for long periods of time? So I continued on with my project and added the walk animation. Got that working good using Basic Player Movement script from the wiki. When I stand, the 'stand' animation cycles and when I move, the 'walk' animation cycles, so glad to have that working. Regardless though with the current script no matter what state I am in at 45 seconds the animation runs wild still. Hmm.

Originally Posted By: EvilSOB
PS: Welcome aboard.


Thanks grin I remember a time when I used to stay up all night trying to figure out code. Lately I've been staying up all night playing games, so pretty thrilled I am rekindling my passion for coding again.
Posted By: EvilSOB

Re: ANM_CYCLE - workshop 21 - problem - 03/15/09 15:53

Yeah, %= does the same I believe.
Im a bit too very-old-school to use the =operators "naturally".
I do that sort of thing at 'clean up and document code' time smile

Let keep at it anyway. The sample you posted in your initial post is
your 'walk'ing animation, can you post the code thats around the code
that handles your 'stand' animation instead? And do you use the templates?
And are you using lite-c or c-script?
Posted By: Sonne

Re: ANM_CYCLE - workshop 21 - problem - 03/15/09 18:20

Well I have no problem posting my code but since I can replicate the identical issue in the Official Online Tutorial I figured more people have gone through it so maybe more familiar with the script.

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>

///////////////////////////////

var walk_percentage;
var death_percentage;

function main()
{
	video_mode = 7;
	level_load ("work21.wmb");
	wait (2); // wait until the level is loaded 
	camera.z = 120; // choose a convenient height
	camera.tilt = -15; // and tilt angle for the camera
}

action walking_guard()
{ 
	wait (-35); // added this as a test
	while (1) 
	{ 
		ent_animate(my,"walk",walk_percentage, ANM_CYCLE); // "walk" animation loop
		walk_percentage += 3 * time_step; // 3 = animation speed for "walk"
		wait (1); 
	} 
} 

action dead_guard()
{ 
	wait (-5); // wait 5 seconds
	while (1) 
	{ 
		ent_animate(my, "death", death_percentage, 0); // "death" one-shot animation 
		death_percentage += 3 * time_step; // 2  = animation speed for "death"
		wait (1); 
	} 
}


I decided to re-download the tutorial files and try it again from scratch. There was a difference, now instead of 45 second delay it is now 25-30 seconds. Ha. I noticed playing with my script the animate seems independent of any values and is based on time which, would be bizarre. So to test this I added the wait (-35); in the above script and as soon as the wait completed the animate went straight into whacko mode ignoring the 'walk' and playing all frames of the model. I put the 'death' entity on ANM_CYCLE mode as well and just like walk after the period of time it cycled through all frames. Thus I was thinking it was something with ANM_CYCLE. Just ran a test with the wait 35 animate with a mode 0 and though it did only perform one animation it cycled through all of them. So it appears that after some time frame of 25-45 seconds ent_animate ignores the animation_name. I doubt it would be software issue because if it were, there would be much more chaos about it. So the only other possibility if it is something they attached to the trial version. Anyone else with trial and the litec-samples workshop want to run workshop 21 until it times-out to see if the walking guard behaves abnormally? I'm always up for new options.

Here is my code. Sloppy, just piecing things here and there to learn 3DGS. Other than this animation issue it works just the way I am hoping it to at this point.

Code:
////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

////////////////////////////////////////////////////////////////////////////////////
ENTITY* player;
VECTOR temp;
var anim_percent = 0;
var dist_ahead = 0;
var dist_down = 0;

function main()
{
	video_mode = 7;
	level_load ("test.wmb");
	wait (2);
	}

action move_me()
{
	while (1)
	{
		if (key_a) me.pan += 10 * time_step;
		if (key_d) me.pan -= 10 * time_step;
		camera.x = me.x + fcos(my.pan,-1 * 250);
		camera.y = me.y + fsin(my.pan,-1 * 250);
		vec_diff(temp.x,me.x,camera.x); //make the camera look towards the player
		vec_to_angle(camera.pan,temp.x);
		camera.z = 25;
		camera.tilt = -20;

      var dist_ahead = 5*(key_w-key_s)*time_step;
      dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*dist_down); // adapt the speed on slopes
      c_move(me,vector(dist_ahead,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player

		// animate the player according to its moved distance
      if (dist_ahead != 0) // player is moving ahead
      {
         anim_percent += 1.7*dist_ahead; // 1.7 = walk cycle percentage per quant
         ent_animate(me,"walka",anim_percent,ANM_CYCLE); // play the "walk" animation
      }

      else // player stands still
      { 
         anim_percent += 5*time_step; 
         ent_animate(me,"stand",anim_percent,ANM_CYCLE); // play the "stand" animation
      }
		wait (1);
	}
}


Originally Posted By: EvilSOB
And do you use the templates?
And are you using lite-c or c-script?


Don't use templates though dabbled with one briefly only to be more confused. I prefer from scratch, 1 line at a time method. I use lite-c. Downloaded the free trial ... day before yesterday, I think.
Posted By: EvilSOB

Re: ANM_CYCLE - workshop 21 - problem - 03/16/09 09:59

Unless anyone else has any ideas, Im stumped. Your code has been running
untouched on my machine for half an hour in "stand" mode and he is still
just looking around, not going spastic at all.

Maybe create a new level with just your entity in it on a big ground block
and see how that goes...

PS - Im currently using A7 7.70 commercial on a dogbox of a computer(here at work).
Posted By: Sonne

Re: ANM_CYCLE - workshop 21 - problem - 03/16/09 11:21

Thanks Evil. At least that is reassuring that it is definitely not a problem with the script. When I get home from work tonight I'll start on a new project with a new model and new WED environment and see if the issue reoccurs. I'm not too hopeful though since the problem also occurs on the workshop files as well.
Posted By: EvilSOB

Re: ANM_CYCLE - workshop 21 - problem - 03/16/09 11:33

It may be just a faulty install of your engine.
Maybe try a re-install too.
Otherwise maybe log a post in the bugs section.

Im not implying anything, but if its a hacked copy,
or youve ever had a hacked copy if 3DGS on that computer,
the hacked copies damage some registry settings so even a
legit copy of of 3DGS wont work perfectly on that machine
until a windows re-install, or so Ive been led to believe.

Posted By: Sonne

Re: ANM_CYCLE - workshop 21 - problem - 03/17/09 01:08

I emailed support with this issue as well. I uninstalled using the uninstaller and reinstalled. No change.

Here it gets weirder. I decided to get the trial fraps to show what is happening since its hard to reproduce. While fraps is recording it does not happen. How bizarre is that. As soon as it stopped recording animation went crazy again. So I tried to continuously record but it did it in between recordings. Trial fraps only allows 30 seconds of recording at a time. So how does fraps affect 3dgs at all. So maybe it is something with my system, so I updated my video driver but that didn't help.


Posted By: EvilSOB

Re: ANM_CYCLE - workshop 21 - problem - 03/17/09 06:01

Only reason (that I can think of) that fraps may affect it is to lower the 3DGS framerate cause
fraps is using horsepower.
Try putting fps_max = 60; at the start of main to see if anything changes.
Posted By: Sonne

Re: ANM_CYCLE - workshop 21 - problem - 03/17/09 11:52

Originally Posted By: EvilSOB
Only reason (that I can think of) that fraps may affect it is to lower the 3DGS framerate cause
fraps is using horsepower.
Try putting fps_max = 60; at the start of main to see if anything changes.


Awesome, a fps max of 60, the animation was normal for about 180 seconds. Then I set the max 40 and it remained normal for 270 seconds. At 30 I was able to have the animation remain normal for the whole duration of the trial engine. Woot! Though it got me a little confused because I always thought the higher the fps the better. Until I read the section on frame rate in the manual..

Why would you want to decrease the frame rate? There are three reasons. Your movement functions might only work properly within a certain frame rate range, and fail at 1000 fps. You won't want your application to consume all the CPU cycles. And most important, you want to avoid stuttering. Stuttering means a camera and actor movement that appears unsteady. It won't be noticeable in a game with complex levels and medium frame rate, but mostly in games with almost empty levels, little content, and consequently very high frame rate that is then capped by fps_max.

The main reason for stuttering is a coarse PC scheduler resolution that leads to inaccurate task start times, especially when many tasks are running on a particular PC. This problem can be avoided by limiting the frame rate not only with fps_max that just gives task time back to the Windows task scheduler, but by really burning CPU cycles in some or the other way. Fortunately, this is easily done. If your game experiences stuttering, just place some more details in your levels for avoiding a too-high frame rate.


So I assume this could be happening because my project and the workshops are, as of now, too simple and when I add more things to the level then I may not have to limit the fps. Thanks very much Evil!
Posted By: EvilSOB

Re: ANM_CYCLE - workshop 21 - problem - 03/17/09 12:02

Good thinking. I would ALSO be inclined to do a full virus/malware scan of
your computer. Its easy to have many malware's (each of which will be seen as
a separate "task" by windows) running in the background, requiring lots of
un-necessary cpu horsepower.
Unless you have a very under-powered computer for programming 3DGS.
What are your PC's specs... CPU, RAM, VideoCard, and free HardDrive space.
Posted By: Valdsator

Re: ANM_CYCLE - workshop 21 - problem - 03/22/09 03:54

I have this problem too. I made a simple little room with a guard that you can walk around with. If I get the full version of GameStudio, won't this problem return because there's no "trial test limit?" Or does a full version completely prevent this?
Posted By: EvilSOB

Re: ANM_CYCLE - workshop 21 - problem - 03/22/09 04:36

I still dont know whats actually causing the problem, so its hard to say.
Are you PC-literate enough to get the task-manager's 'cpu-usage graph' to display?
If it is going over 75% when you run the level, it may be too much for your machine, or MOST
likely youve got a malware problem.

I also have no idea of the impact Vista may cause if you have it.

NOTE TO ALL: I have never been able to re-produce this problem except through faulty coding...
© 2024 lite-C Forums