6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood),
1,268
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
how to stop the mdl from walking when it is near the player
#306309
01/21/10 05:23
01/21/10 05:23
|
Joined: Jan 2010
Posts: 4
Hissatsu
OP
Guest
|
OP
Guest
Joined: Jan 2010
Posts: 4
|
just want to ask what code should i put inside the while to trigger my if statement. when the gap between the 2 entities is less than 100. the other mdl should stop walking and perform an attack.
var gap = vec_dist(my.x, your.x); while(1) {
if(gap >= 100) { var distance =-3*time_step; c_move(me, vector(0,distance,0), NULL, GLIDE); my.ANIMATION += 2* distance; ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE); if(gap < 100) { my.ANIMATION = 0; my.ANIMATION += 25 * time_step; ent_animate(my, "attack", my.ANIMATION,ANM_CYCLE); }
} wait(1); }
|
|
|
Re: how to stop the mdl from walking when it is near the player
[Re: Hissatsu]
#306311
01/21/10 05:47
01/21/10 05:47
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
var distance = 0;
while(1)
{
if(vec_dist(my.x, your.x)>= 100)
{
distance =-3*time_step;
c_move(me, vector(0,distance,0), NULL, GLIDE);
my.ANIMATION += 2* distance;
ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);
}
else
{
my.ANIMATION = 0;
my.ANIMATION += 25 * time_step;
ent_animate(my, "attack", my.ANIMATION,ANM_CYCLE);
}
wait(1);
}
You need to calculate the distance every frame, so it goes inside the while loop.
Last edited by DJBMASTER; 01/21/10 05:48.
|
|
|
Re: how to stop the mdl from walking when it is near the player
[Re: Hissatsu]
#306328
01/21/10 07:57
01/21/10 07:57
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
The error is probably caused because either 'my' and/or 'your' is not set to a valid ENTITY*, so make sure 'my' and 'your' are both valid.
Last edited by DJBMASTER; 01/21/10 07:58.
|
|
|
|