Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 7th_zorro), 923 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
make entity move over fixed time #225158
09/03/08 04:08
09/03/08 04:08
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
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...


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: make entity move over fixed time [Re: delinkx] #225187
09/03/08 08:50
09/03/08 08:50
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
anyone for help ?


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
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
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
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.

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 Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
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 ?


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
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 Offline OP
User
delinkx  Offline 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.

A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
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
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
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);
}


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 Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
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
}
}


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: make entity move over fixed time [Re: delinkx] #225341
09/04/08 04:37
09/04/08 04:37
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
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?

Re: make entity move over fixed time [Re: vlau] #225349
09/04/08 05:23
09/04/08 05:23
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline OP
User
delinkx  Offline OP
User

Joined: Jul 2008
Posts: 553
Singapore
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 ??


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook

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