2 registered members (NnamueN, 1 invisible),
1,489
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
make model move in direction of player
#315291
03/14/10 14:58
03/14/10 14:58
|
Joined: Sep 2009
Posts: 155 France
ayks
OP
Member
|
OP
Member
Joined: Sep 2009
Posts: 155
France
|
Hi, i'm looking for a code. i want the model to, when distance between player and model < 500 : 1)looks the player 2)move in direction of player until it touch the player. i have no problem for check distance and make the model looks the player : while (vec_dist(player.x, me.x)>300){wait(1);} vec_set(temp,player.x);vec_sub(temp,my.x);vec_to_angle(my.pan,temp); // now MY looks at YOU
but i don't know how to make the model move in direction of player after it if someone can give me the code for it.. thx :l ps : i think it can be done with "position" but i'm looking for a easier solution with "vec" in a first time.
Last edited by ayks; 03/14/10 14:59.
|
|
|
Re: make model move in direction of player
[Re: alibaba]
#315310
03/14/10 17:11
03/14/10 17:11
|
Joined: Sep 2009
Posts: 155 France
ayks
OP
Member
|
OP
Member
Joined: Sep 2009
Posts: 155
France
|
already found it but it's complicated -. i always get the same answer when i post in this forum so it bores me so i always search everywhere before asking -. thx anyway, wasn't sure i had to use move_c but i focused on it and did ~something correct, very weird but it ~works while (vec_dist(player.x, me.x)>50) { vec_set(temp,player.x);vec_sub(temp,my.x);vec_to_angle(my.pan,temp); distmx=0.1*abs(player.x-my.x); distmy=0.1*abs(player.x-my.x); c_move (my, vector(distmx, distmy, 0), nullvector, GLIDE);wait(2); } beep();
-.
|
|
|
Re: make model move in direction of player
[Re: ayks]
#315345
03/14/10 20:30
03/14/10 20:30
|
Joined: May 2008
Posts: 2,113 NRW/Germany
alibaba
Expert
|
Expert
Joined: May 2008
Posts: 2,113
NRW/Germany
|
ok i wrote this code for you action blabla() { while(vec_dist(my.x,player.x)>500)wait(1); while (1) { vec_set(temp.x,player.x); vec_sub(temp.x,my.x); vec_to_angle(my.pan,temp.x); c_move (my, vector(5, 0, 0), nullvector, GLIDE+IGNORE_ME+IGNORE_YOU); wait(1); } } so thats the whole code for let an NPC walk to player if the lpayer is nearer than 500 quants, rotate it to the player and move it to the player. you made it too complicated, its easier than it seems @Progger Your code has nothing to do with this topic. this code just set ups an Entity in front of the player and let it rotate with the player.
Last edited by alibaba; 03/14/10 20:32.
|
|
|
Re: make model move in direction of player
[Re: alibaba]
#315350
03/14/10 21:00
03/14/10 21:00
|
Joined: Sep 2009
Posts: 155 France
ayks
OP
Member
|
OP
Member
Joined: Sep 2009
Posts: 155
France
|
cool looks damn basic (one line for what i needed) but works perfectly. my code was doing "weird circly moves" + was far to perfect :l and indeed it looks easier than my code which don't work but when I don't know the good 'formula', I do what I can + 1 step clear, thx :}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|