Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (NnamueN, 1 invisible), 1,489 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Member
ayks  Offline 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 :

Quote:

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 smirk
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: ayks] #315296
03/14/10 15:17
03/14/10 15:17
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
if you search for "move" in the manual, then you will see a function called "c_move" wink

Always search in the manual, then ask. laugh


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
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 Offline OP
Member
ayks  Offline 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


Quote:

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] #315322
03/14/10 18:40
03/14/10 18:40
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
try this perhaps it helps that is a code of my soccer game

Member

Registered: 09/21/09
Posts: 117
here is a code of my football game

function attach_ba()
{

while(Ball==NULL){wait(1);}
while(1)
{

set(Ball,SHADOW);
proc_mode = PROC_LATE;
Ball.material = mat_metal;
Ball.x = player.x + 50 * cos(player.pan);
Ball.y = player.y + 50 * sin(player.pan);
Ball.z = player.z-41;
Ball.pan=player.pan;

Ball.tilt+=5 ;

wait(1);
}
}

WFG Progger


asking is the best Way to get help laugh laugh laugh
Re: make model move in direction of player [Re: Progger] #315335
03/14/10 20:00
03/14/10 20:00
Joined: Sep 2009
Posts: 155
France
ayks Offline OP
Member
ayks  Offline OP
Member

Joined: Sep 2009
Posts: 155
France
huh, hm thanks but it looks more weird than my weird code, I'm not sure that it's appropriate for what i want to do :l
good luck for your football game :l

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 Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
ok i wrote this code for you laugh


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 wink



@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.

Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
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 Offline OP
Member
ayks  Offline OP
Member

Joined: Sep 2009
Posts: 155
France
cool laugh
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 smirk
+ 1 step clear, thx :}

Re: make model move in direction of player [Re: ayks] #315354
03/14/10 21:13
03/14/10 21:13
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
no problem laugh


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de

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