make entity move over fixed time

Posted By: delinkx

make entity move over fixed time - 09/03/08 04:08

hi,

i am trying to do this but not able to. I have 10 entities (an animated model). I want it to move from point P1 to point P2 over time T seconds. and animating it during tat movement. (each entity has its own P1 and P2 which i already stored).

i have tried this but doesnt work.

for(i=0; i<10; i++)
{
c_move(entAgent[i], vector(distance, 0, 0), nullvector, GLIDE);
anim_percent += 0.25 * time_step;
ent_animate(entAgent[i], "walk", anim_percent, ANM_CYCLE);
wait(-0.1);
}

.......

here distance is calcultated and T = 0.1 seconds. The motion is proper but the animation is not happening. and am not sure if the agent is taking 0.1 seconds to move over that distance. any help plz...
Posted By: delinkx

Re: make entity move over fixed time - 09/03/08 08:50

anyone for help ?
Posted By: vlau

Re: make entity move over fixed time - 09/03/08 09:29

Assign the following action to your models :
Code:
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.
Posted By: delinkx

Re: make entity move over fixed time - 09/04/08 03:12

Originally Posted By: vlau
Assign the following action to your models :
Code:
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 ?
Posted By: delinkx

Re: make entity move over fixed time - 09/04/08 03:34

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);
Posted By: vlau

Re: make entity move over fixed time - 09/04/08 03:47

Another suggestion, you could try calling a function
in a for/while loop.

Code:
while(1)
{
  for (k=0; k<agent_count; k++)
  {
    moveObj(ENTITY* ent, VECTOR pos);  
  }
  k = 0;
  wait(-0.1);
}

Posted By: delinkx

Re: make entity move over fixed time - 09/04/08 03:56

Originally Posted By: vlau
Another suggestion, you could try calling a function
in a for/while loop.

Code:
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
}
}
Posted By: vlau

Re: make entity move over fixed time - 09/04/08 04:37

You may try :

for(all_entities)
{
while(moving from point P1 to P2 during time 0.1 seconds)
{
while(anim_percent < 100)
{
anim_percent += speed * time_step; // play with speed
//animate the walk
}
}
}


There is a snippet that does the similar
thing was posted in the forum if I remember
it right, you may search the forum.

Btw, how can you see the model animates
in such a short time?
Posted By: delinkx

Re: make entity move over fixed time - 09/04/08 05:23

i did try searching the forum. but getting nothing much. how to see the model animating is every 0.1 seconds it keeps moving.. so overall we get the movement. like moving from P1 to P2 to P3.... on n on..

anyone for help plz ??
© 2024 lite-C Forums