2 registered members (AndrewAMD, 7th_zorro),
1,285
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: make entity move over fixed time
[Re: delinkx]
#225196
09/03/08 09:29
09/03/08 09:29
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Assign the following action to your models :
action moveObj()
{
while(my)
{
while(my.skill2 < 100)
{
c_move(my,vector(my.skill1*time_step,0,0),nullvector,GLIDE);
my.skill2 += 5 * time_step; // 5 = animation speed
ent_animate(my,"walk",my.skill2,ANM_CYCLE);
wait(1);
}
my.skill2 = 0; // reset animation percentage
wait(-0.1);
}
}
You may edit different movement speed "skill1" to your models in WED.
|
|
|
Re: make entity move over fixed time
[Re: vlau]
#225332
09/04/08 03:12
09/04/08 03:12
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
OP
User
|
OP
User
Joined: Jul 2008
Posts: 553
Singapore
|
Assign the following action to your models :
action moveObj()
{
while(my)
{
while(my.skill2 < 100)
{
c_move(my,vector(my.skill1*time_step,0,0),nullvector,GLIDE);
my.skill2 += 5 * time_step; // 5 = animation speed
ent_animate(my,"walk",my.skill2,ANM_CYCLE);
wait(1);
}
my.skill2 = 0; // reset animation percentage
wait(-0.1);
}
}
You may edit different movement speed "skill1" to your models in WED. i cannot use an action here. as am reading a set of array values for the distance to be moved. my array values are like this: "move, agent_ID, x, y, z" - for each entity. the time between 2 values is 0.1 seconds. can i implement it in my for loop which i posted in my earlier post ?
|
|
|
Re: make entity move over fixed time
[Re: delinkx]
#225335
09/04/08 03:34
09/04/08 03:34
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
OP
User
|
OP
User
Joined: Jul 2008
Posts: 553
Singapore
|
i did try put it in the for loop. but doesnt work. the agents dont move at all now. and sudden movements are there.
code:
for (k=0; k<agent_count; k++) {
vec_set(temp,vector(toAgent[k].xpos, toAgent[k].ypos, 2.8)); vec_sub(temp,vector(fromAgent[k].xpos, fromAgent[k].ypos, 2.8)); vec_to_angle(fromAgent[k].entAgent.pan,temp); distance = vec_dist(vector(toAgent[k].xpos, toAgent[k].ypos, 0), vector(fromAgent[k].xpos, fromAgent[k].ypos, 0)); while(anim_percent < 100) { c_move(fromAgent[k].entAgent, vector(distance, 0, 0), nullvector, IGNORE_WORLD | IGNORE_MODELS | IGNORE_PASSABLE); //animate anim_percent += 5 * time_step; ent_animate(fromAgent[k].entAgent, "walk", anim_percent, ANM_CYCLE); //saving values wait(1); } anim_percent = 0; fromAgent[k].xpos = toAgent[k].xpos; fromAgent[k].ypos = toAgent[k].ypos; } wait(-0.1);
Last edited by delinkx; 09/04/08 03:35.
|
|
|
Re: make entity move over fixed time
[Re: delinkx]
#225336
09/04/08 03:47
09/04/08 03:47
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Another suggestion, you could try calling a function in a for/while loop.
while(1)
{
for (k=0; k<agent_count; k++)
{
moveObj(ENTITY* ent, VECTOR pos);
}
k = 0;
wait(-0.1);
}
|
|
|
Re: make entity move over fixed time
[Re: vlau]
#225337
09/04/08 03:56
09/04/08 03:56
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
OP
User
|
OP
User
Joined: Jul 2008
Posts: 553
Singapore
|
Another suggestion, you could try calling a function in a for/while loop.
while(1)
{
for (k=0; k<agent_count; k++)
{
moveObj(ENTITY* ent, VECTOR pos);
}
k = 0;
wait(-0.1);
}
this is ok. calling the moveObj function i can make the entity move, but how to animate it while its moving ? tats the tricky part am not getting. i want to do something like this: (algo): for(all_entities) { while(moving from point P1 to P2 during time 0.1 seconds) { animate the walk } }
|
|
|
|