|
1 registered members (codeChallenged),
16,375
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: calculating vec_dist as part of an action
[Re: Quad]
#325756
05/27/10 23:40
05/27/10 23:40
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
Thanks! that stoppped the crash, now I'll try implementing it in other functions.
I know I can.
|
|
|
Re: calculating vec_dist as part of an action
[Re: gameaddict]
#325759
05/28/10 00:09
05/28/10 00:09
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
Thanks! it works. but the function crashes when I press any button. Please take a look at my functions, I must be doing something wrong. I've tried different things but they cause more or less the same result. The action:
action theBall()
{
while(!player) wait(1);
set(my, SHADOW);
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 1, PH_SPHERE);
phent_setfriction(my,90);
phent_setelasticity(my,75,100);
phent_setdamping(my,30,5);
phent_addvelcentral(my,vector(10,10,0));
ph_setgravity(vector(0,0,-500));
my.emask |= ENABLE_FRICTION;
while(1){
dist = vec_dist(my.x, player.x);
if(key_w || key_a || key_s || key_d){
move_with_ball();
}
if(key_x){
kick();
}
wait(1);
}
}
The function:
function move_with_ball()
{
while(!my) wait(1);
while(1){
if(dist <= 20){
proc_mode = PROC_LATE;
my.x = player.x + 15 * cos(player.pan);
my.y = player.y + 15 * sin(player.pan);
my.z = player.z - 15;
my.pan=player.pan;
my.roll+=2;
my.tilt+=2;
}
if(key_x){
kick();
}
}
wait(1);
}
Thanks.
I know I can.
|
|
|
Re: calculating vec_dist as part of an action
[Re: gameaddict]
#325762
05/28/10 00:22
05/28/10 00:22
|
Joined: Apr 2010
Posts: 265
Vinous_Beret
Member
|
Member
Joined: Apr 2010
Posts: 265
|
function move_with_ball() {
while(!my) wait(1);
while(1){ if(dist <= 20){ proc_mode = PROC_LATE; my.x = player.x + 15 * cos(player.pan); my.y = player.y + 15 * sin(player.pan); my.z = player.z - 15; my.pan=player.pan; my.roll+=2; my.tilt+=2; } if(key_x){ kick(); }
} wait(1); } "wait(1)" is outside while loop, try this: function move_with_ball() {
while(!my) wait(1);
while(1){ if(dist <= 20){ proc_mode = PROC_LATE; my.x = player.x + 15 * cos(player.pan); my.y = player.y + 15 * sin(player.pan); my.z = player.z - 15; my.pan=player.pan; my.roll+=2; my.tilt+=2; } if(key_x){ kick(); } wait(1); } }
|
|
|
Re: calculating vec_dist as part of an action
[Re: DJBMASTER]
#326609
06/01/10 19:58
06/01/10 19:58
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
Thanks guys, it worked! The only problem is that when I call the kick function, the ball is kicked from it's original position and not from where the player has moved to. I've not been able to figure out how to update the original ball position so it doesn't move to it's original position before been kicked. Could someone help me out?
I know I can.
|
|
|
|