Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,397 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Animation FPS speed #125926
04/24/07 01:18
04/24/07 01:18
Joined: Jul 2006
Posts: 91
Florida, USA
Knuckles Offline OP
Junior Member
Knuckles  Offline OP
Junior Member

Joined: Jul 2006
Posts: 91
Florida, USA
How do I go about changing the animation speed of an entity? I've looked all in my animate() functions and I can't figure out why the animation is so fast. The animation goes so fast it literally looks like a blur on the screen. Whether running it fullscreen or windowed, it still does the same thing.

this is what the walk animation looks like:

Code:
  

var wait_start=0;
var wait_end=1;
var player_walk_frames[2]= 22,42;

function animate_walk()
{
while(1)
{

if((player.frame > player_walk_frames[wait_end]) || (player.frame < player_walk_frames[wait_start]))
{
player.frame = player_walk_frames[wait_start];
}

player.frame += 0.7 * time;


wait(1);
}
}





I've tried adjusting the animation time and player speed, but nothing seems to work. Here's a screenshot of some extra F11 info on the screen when I run the program in case this helps:


Re: Animation FPS speed [Re: Knuckles] #125927
04/24/07 02:12
04/24/07 02:12
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Are you using vertex or bones animation?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Animation FPS speed [Re: MrCode] #125928
04/24/07 03:06
04/24/07 03:06
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Code:

while(1)
{
temp.x = 0.7 * time_step; // speed
temp.y = player_walk_frames[wait_start]; // min
temp.z = player_walk_frames[wait_end]; // max
player.frame = cycle(player.frame + temp.x, temp.y, temp.z);
wait(1);
}




Also try lowering the 0.7 considerably. I think it's way too high.

Also, another (much easier) way of animating is to use the ent_animate() function...


xXxGuitar511
- Programmer
Re: Animation FPS speed [Re: MrCode] #125929
04/24/07 04:01
04/24/07 04:01
Joined: Jul 2006
Posts: 91
Florida, USA
Knuckles Offline OP
Junior Member
Knuckles  Offline OP
Junior Member

Joined: Jul 2006
Posts: 91
Florida, USA
Quote:

Are you using vertex or bones animation?




>_> how do I find that out?

guitar: I'll try it and see, thanks!

Re: Animation FPS speed [Re: Knuckles] #125930
04/24/07 19:09
04/24/07 19:09
Joined: Jul 2006
Posts: 91
Florida, USA
Knuckles Offline OP
Junior Member
Knuckles  Offline OP
Junior Member

Joined: Jul 2006
Posts: 91
Florida, USA
It's still not working. I tried resetting the bones to NULL using the ent_animate function. I am not sure if the model is using bones or vertex animation. How do I check this?

btw, I'm utilizing the 'click and go' script to get walk animations. As I said, everything works fine except that the walking (and standing) animations are going crazy. It's as if it's either an infinite loop somewhere or the program is trying to get more than one different value for the location of the model which is causing it to do this blur animation thing. But I've checked the code and I don't see anything like that happening. I really don't know what's up.

Re: Animation FPS speed [Re: Knuckles] #125931
04/24/07 19:54
04/24/07 19:54
Joined: Jul 2000
Posts: 8,973
Bay Area
Doug Offline
Senior Expert
Doug  Offline
Senior Expert

Joined: Jul 2000
Posts: 8,973
Bay Area
Just some hints:
- First look at limited your FPS to something like 90. This probably isn't the issue but there is no reason why you should be running at 170+ FPS.
- Second use ent_animate() instead of setting the frame directly. This makes your life easier.

Neither of these will solve your problem however, but (looking at the fact that the debug panels shows you having over 23,000 functions running) I'm going to guess that you call your animate_walk() function more than once for each entity (maybe inside a loop?).

Since your animate_walk() function has an an enless loop it never exits. It runs once each frame. When you call it again, you are creating another animate_walk() loop that does the same thing. Since they are updating the same value (frame), that value will increase twice as fast.

This can quickly add up (frame 1 = 0.7, frame 2 = 1.4, frame 10 = 7). After one second at 171 FPS you will be increasing by 119.7 units every frame!

Make sure you call animate_walk() only once per entity -or- remove the while(1) loop.


Conitec's Free Resources:
User Magazine || Docs and Tutorials || WIKI
Re: Animation FPS speed [Re: Doug] #125932
04/24/07 20:05
04/24/07 20:05
Joined: Jul 2006
Posts: 91
Florida, USA
Knuckles Offline OP
Junior Member
Knuckles  Offline OP
Junior Member

Joined: Jul 2006
Posts: 91
Florida, USA
I don't understand how the animate_walk function is an endless loop since it has a wait(1) at the end? Usually if I leave out the wait(1) I get a message saying that it's an endless loop.

Do I need to add a return function after the wait(1)?

Last edited by Knuckles; 04/24/07 20:06.
Re: Animation FPS speed [Re: Knuckles] #125933
04/24/07 20:38
04/24/07 20:38
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
i guess u didnt understand doug right...he means:do you call every frame the same funtion that also run in a loop?

Re: Animation FPS speed [Re: Scorpion] #125934
04/24/07 23:33
04/24/07 23:33
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
RE: Vertex/Bones animation

If you animated your model by clicking and dragging the verticies for every frame, then you are using vertex animation. If you are creating a virtual "skeleton" made out of "bones" and moving them for every frame, then you are using bones animation. (this type of animation can also be blended with code).

EDIT: If you're using vertex animation, this is a much easier way to do it:

Code:

var walk_speed;
var breath_speed;
var jump_speed;

...

action char_walk
{
my.fat= on;
my.narrow= on;
c_setminmax(my);
while(1)
{
if(key_cuu== on)
{
c_move(my,vector(0,6 * time_step,0),nullvector,glide);
ent_animate(my,"walk",walk_speed,anm_cycle);
walk_speed+= 10 * time_step;
}
else
{
ent_animate(my,"stand",breath_speed,anm_cycle);
breath_speed+= 3 * time_step;
}
if(key_cud== on)
{
c_move(my,vector(0,-6 * time_step,0),nullvector,glide);
ent_animate(my,"walk",walk_speed,anm_cycle);
walk_speed+= 10 * time_step;
}
if(key_cul== on)
{
my.pan+= 10 * time_step;
}
if(key_cur== on)
{
my.pan-= 10 * time_step;
}
if(key_j== on)
{
c_move(my,vector(0,0,15 * time_step),nullvector,glide);
ent_animate(my,"jump",jump_speed,anm_cycle);
jump_speed+= 14 * time_step;
}
else
{
c_move(my,vector(0,0,-15 * time_step),nullvector,glide);
}



Mabye it's not any shorter than your current code, but this would allow your char to move and turn w/ the arrow buttons, and jump with the J key.

Last edited by MrCode; 04/24/07 23:39.
Re: Animation FPS speed [Re: MrCode] #125935
04/25/07 00:10
04/25/07 00:10
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
But better one is bone animations of'course.
Maybe is a little slower but a lot of easyer to create.
1. create bones
2. Attach vertex to bones
3. make some simple animation and name it f.e. test
4. then in player loop add f.e. make_animation();
5. create function with the same name (make_animate)
Code:

action player
{
....
.....
make_animate();
}



then make_animate function
Code:
 
define anim_speed, skill1;
function make_animate
{
my.anim_speed += 3 * time_step; // how fast animation should be
ent_animate(me,NULL,0,0); // reset bones every loop
ent_animate(me,"test",my.anim_speed,anm_cycle); //animate
}



After all the best way to learn is practice and reading help
Check f.e thisclick and go and find animation part.


Never say never.
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1