2 registered members (TipmyPip, AndrewAMD),
14,540
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
An issue about running slowly
#205215
05/05/08 08:08
05/05/08 08:08
|
Joined: Nov 2007
Posts: 37
LavenderSs
OP
Newbie
|
OP
Newbie
Joined: Nov 2007
Posts: 37
|
Hi, everyone. I encountered a difficult problem that has been troublesome to me these days. Have a general depiction, I've written some code that make an entity (actually a person) take some continuous movement, that is, first walking, then running, then jumping, and then standing. Every kind of action would last for a couple of seconds. All of this works well until here.(Here such process of taking actions could be called a 'showing') But as soon as I let 'showing' run for the second time or even more. The entity's action couldn't be the same as the first time's showing. It walks for a very short distance and jumps much higher than the first time, though the animtion speed of entity isn't changed compared with the fist time. I firstly thought the issue could be caused by the too much occupation of memory space since an entity may cosume amounts of memory. I tried to add some functions just like 'ent_purge' or 'ent_remove' while the entity isn't being used. (Btw, I created the entity in WED). The problem doesn't seem to be figured out. Each action is taken for much shorter distance than the first time. Has anyone met the problem like this and how to solve it ?? I am really grateful for your reply and help.
Many thanks!!
Last edited by LavenderSs; 05/05/08 08:17.
|
|
|
Re: An issue about running slowly
[Re: LavenderSs]
#205218
05/05/08 08:21
05/05/08 08:21
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
Do you use time_step in your movement code? Sounds like you move your entity effected by changing framerates. To avoid framerate related changing of movespeeds/-distances use time_step.
|
|
|
Re: An issue about running slowly
[Re: LavenderSs]
#205219
05/05/08 08:22
05/05/08 08:22
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
sounded like a absence of time_step s to me. check time_step at manual and see what it can do for you 
Last edited by Quadraxas; 05/05/08 08:22. Reason: mercuryus was faster.
3333333333
|
|
|
Re: An issue about running slowly
[Re: LavenderSs]
#205226
05/05/08 08:59
05/05/08 08:59
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
Better you post the movement snippet than the animation snippet if you have troubles with the movement code?
but first check all lines/variables effecting your movement-variables...
|
|
|
Re: An issue about running slowly
[Re: ]
#205261
05/05/08 13:34
05/05/08 13:34
|
Joined: Nov 2007
Posts: 37
LavenderSs
OP
Newbie
|
OP
Newbie
Joined: Nov 2007
Posts: 37
|
OK. The code is as follows:
exec_seconds = 6; start_sec = sys_seconds; //walking while(1) { c_move (guard, vector(1, 0, 0), nullvector, GLIDE); guard.pan -= 1 * time_step; ent_animate(guard,"walk",auto_play_percentage, ANM_CYCLE); auto_play_percentage += 6 * time_step; if((start_sec + exec_seconds) % 60 == sys_seconds) break; else { int temp_sec = sys_seconds; if(temp_sec > 0 && temp_sec <5) temp_sec += 60; if((temp_sec - start_sec) > 2)//turn right guard.pan += 3.5 * time_step; } wait(1); } //crawling exec_seconds = 4; start_sec = sys_seconds; guard.z = 29; while(1) { c_move (guard, vector(0.5, 0, 0), nullvector, GLIDE); ent_animate(guard,"crawl",auto_play_percentage, ANM_CYCLE); auto_play_percentage += 8 * time_step; guard.pan += 1.5 * time_step; if((start_sec + exec_seconds) % 60 == sys_seconds) break; wait(1); } wait(-0.5); //jumping auto_play_percentage = 0; guard.z = 44; wait(-0.5); //rest for 1 min
int one_jump_dist = 160; //the distance of jumping int jump_time = 3; //the time of jumping int jumping_dist = 0; //the realtime distance while jumping (as for one jump) VECTOR start_pos; //the position of starting jumping each time vec_set(start_pos, vector(guard.x,guard.y,0)); //jumping while(1) { c_move (guard, vector(2, 0, 0), nullvector, GLIDE); ent_animate(guard,"jump",auto_play_percentage, ANM_CYCLE); auto_play_percentage += 6 * time_step; jumping_dist = vec_dist(vector(guard.x,guard.y,0), start_pos); if(jumping_dist <= (one_jump_dist/2)) guard.z += 4 * time_step; else if(jumping_dist > (one_jump_dist/2) && jumping_dist < one_jump_dist) guard.z -= 4 * time_step; else if(jumping_dist >= one_jump_dist) { guard.z = 44; jump_time -= 1; vec_set(start_pos, vector(guard.x,guard.y,0)); auto_play_percentage = 0; wait(-0.5); } if(jump_time == 0) break; wait(1); }
//running exec_seconds = 6; start_sec = sys_seconds; auto_play_percentage = 0; while(1) { c_move (guard, vector(2, 0, 0), nullvector, GLIDE); guard.pan += 7 * time_step; ent_animate(guard,"run",auto_play_percentage, ANM_CYCLE); auto_play_percentage += 9 * time_step;//adjust animation with the factor of time_step if((start_sec + exec_seconds) % 60 == sys_seconds) break; else { int temp_sec = sys_seconds; if(temp_sec > 0 && temp_sec <5) temp_sec += 60; if((temp_sec - start_sec) > 1.5) //turn right guard.pan -= 11 * time_step; } wait(1); }
|
|
|
Re: An issue about running slowly
[Re: LavenderSs]
#205270
05/05/08 14:50
05/05/08 14:50
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
...use time_step also in the c_move statements.
e.g.: c_move (guard, vector(1*time_step, 0, 0), nullvector, GLIDE);
and so on...
Read the topic about time_step/time_frame in the handbook to get the idea behind it....
|
|
|
|