0 registered members (),
1,209
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
A little "wait" problem
#218372
07/28/08 09:47
07/28/08 09:47
|
Joined: Aug 2006
Posts: 96 Netherlands
Polypfreak1987
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 96
Netherlands
|
Hello, I have a little problem. I have 5 entities, those are the same models. So I have 1 model to save diskspace and create it 5 times with ent_create. Every entity have this code:
action arm1 {
arm01 = my;
my.passable = on;
vec_for_vertex(temp,my,86);
ent_create("ZTkrzn.mdl",temp,kruis1);
var anim_time = 0;
var anim;
ang_sin = 0;
speed_arm = 0.3;
max_arm = 0;
wait(-1);
while(1) {
vec_for_vertex(temp,ondermolen1,259);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
my.pan = ondermolen1.pan;
ent_animate(my, "windmill", anim, ANM_cycle);
anim += anim_time;
anim_time = 2*time_step;
if(key_r == 1) {
if(max_arm <= 8) {
max_arm += 0.1*time_step;
}
}
if(key_f == 1) {
if(max_arm > 0) {
max_arm -= 0.1*time_step;
}
}
ang_sin += speed_arm;
if(ang_sin >= 360) {
ang_sin += 360;
}
my.tilt = -max_arm+sin(ang_sin) * max_arm;
wait(1);
}
} The only difference is that the first wait-function is different. The other 4 entities have wait(-2), wait(-3) and so on. The problem is that the entities start at the same point as arm1 and then after a couple of seconds jump back to their original position. Is there a sollution for this problem?
|
|
|
Re: A little "wait" problem
[Re: delinkx]
#218454
07/28/08 18:25
07/28/08 18:25
|
Joined: Aug 2006
Posts: 96 Netherlands
Polypfreak1987
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 96
Netherlands
|
one way u can do this:
if ur no of entities are fixed and u know first one has which no of waits, then u create 5 different actions for each with different waits in them. and attach them accordingly as u create the entities.
else within one action only u can give conditions like
if(....)
wait(-1)
else if(...)
wait(-2)
.... ..... Do you mean like this?
function move() {
if(arm01) {
wait(-1);
} else if(arm02) {
wait(-2);
} else if(arm03) {
wait(-3);
} else if(arm04) {
wait(-4);
} else if(arm05) {
wait(-5);
}
} And in the entity-code:
action arm1 {
arm01 = my;
my.passable = on;
vec_for_vertex(temp,my,86);
ent_create("ZTkrzn.mdl",temp,kruis1);
var anim_time = 0;
var anim;
ang_sin = 0;
speed_arm = 0.3;
max_arm = 0;
//wait(-1);
move();
while(1) {
vec_for_vertex(temp,ondermolen1,259);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
my.pan = ondermolen1.pan;
ent_animate(my, "windmill", anim, ANM_cycle);
anim += anim_time;
anim_time = 2*time_step;
if(key_r == 1) {
if(max_arm <= 8) {
max_arm += 0.1*time_step;
}
}
if(key_f == 1) {
if(max_arm > 0) {
max_arm -= 0.1*time_step;
}
}
ang_sin += speed_arm;
if(ang_sin >= 360) {
ang_sin += 360;
}
my.tilt = -max_arm+sin(ang_sin) * max_arm;
wait(1);
}
}
|
|
|
Re: A little "wait" problem
[Re: Polypfreak1987]
#218507
07/29/08 02:27
07/29/08 02:27
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
User
|
User
Joined: Jul 2008
Posts: 553
Singapore
|
one way u can do this:
if ur no of entities are fixed and u know first one has which no of waits, then u create 5 different actions for each with different waits in them. and attach them accordingly as u create the entities.
else within one action only u can give conditions like
if(....)
wait(-1)
else if(...)
wait(-2)
.... ..... Do you mean like this?
function move() {
if(arm01) {
wait(-1);
} else if(arm02) {
wait(-2);
} else if(arm03) {
wait(-3);
} else if(arm04) {
wait(-4);
} else if(arm05) {
wait(-5);
}
} And in the entity-code:
action arm1 {
arm01 = my;
my.passable = on;
vec_for_vertex(temp,my,86);
ent_create("ZTkrzn.mdl",temp,kruis1);
var anim_time = 0;
var anim;
ang_sin = 0;
speed_arm = 0.3;
max_arm = 0;
//wait(-1);
move();
while(1) {
vec_for_vertex(temp,ondermolen1,259);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
my.pan = ondermolen1.pan;
ent_animate(my, "windmill", anim, ANM_cycle);
anim += anim_time;
anim_time = 2*time_step;
if(key_r == 1) {
if(max_arm <= 8) {
max_arm += 0.1*time_step;
}
}
if(key_f == 1) {
if(max_arm > 0) {
max_arm -= 0.1*time_step;
}
}
ang_sin += speed_arm;
if(ang_sin >= 360) {
ang_sin += 360;
}
my.tilt = -max_arm+sin(ang_sin) * max_arm;
wait(1);
}
} yeps this should do the work.
|
|
|
Re: A little "wait" problem
[Re: delinkx]
#218575
07/29/08 10:30
07/29/08 10:30
|
Joined: Aug 2006
Posts: 96 Netherlands
Polypfreak1987
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 96
Netherlands
|
So, now I have the following code:
function move() {
if(arm01) {
wait(-1);
} else if(arm02) {
wait(-2);
} else if(arm03) {
wait(-3);
} else if(arm04) {
wait(-4);
} else if(arm05) {
wait(-5);
}
}
action arm1 {
arm01 = my;
my.passable = on;
vec_for_vertex(temp,my,86);
ent_create("ZTkrzn.mdl",temp,kruis1);
var anim_time = 0;
var anim;
ang_sin = 0;
speed_arm = 0.3;
max_arm = 0;
//wait(-1);
move();
while(1) {
vec_for_vertex(temp,ondermolen1,259);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
my.pan = ondermolen1.pan;
ent_animate(my, "windmill", anim, ANM_cycle);
anim += anim_time;
anim_time = 2*time_step;
if(key_r == 1) {
if(max_arm <= 8) {
max_arm += 0.1*time_step;
}
}
if(key_f == 1) {
if(max_arm > 0) {
max_arm -= 0.1*time_step;
}
}
ang_sin += speed_arm;
if(ang_sin >= 360) {
ang_sin += 360;
}
my.tilt = -max_arm+sin(ang_sin) * max_arm;
wait(1);
}
} But when I want to test my game I have these errors: "else if(arm03){" <- Parameter unknown else bad keyword in {} and this one: "wait(-3)" <- Parameter unknown wait bad keyword in {} How can I fix this?
|
|
|
Re: A little "wait" problem
[Re: Tobias]
#218604
07/29/08 13:41
07/29/08 13:41
|
Joined: Aug 2006
Posts: 96 Netherlands
Polypfreak1987
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2006
Posts: 96
Netherlands
|
Thank you, that did work well. But now I have another problem to call the function. I have the following code:
function move() {
if(arm01) {
wait(-1);
} else {
if(arm02) {
wait(-2);
}
} else {
if(arm03) {
wait(-3);
}
} else {
if(arm04) {
wait(-4);
}
} else {
if(arm05) {
wait(-5);
}
}
}
action arm1 {
arm01 = my;
my.passable = on;
vec_for_vertex(temp,my,86);
ent_create("ZTkrzn.mdl",temp,kruis1);
var anim_time = 0;
var anim;
ang_sin = 0;
speed_arm = 0.3;
max_arm = 0;
//wait(-1);
move();
while(1) {
vec_for_vertex(temp,ondermolen1,259);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
my.pan = ondermolen1.pan;
ent_animate(my, "windmill", anim, ANM_cycle);
anim += anim_time;
anim_time = 2*time_step;
if(key_r == 1) {
if(max_arm <= 8) {
max_arm += 0.1*time_step;
}
}
if(key_f == 1) {
if(max_arm > 0) {
max_arm -= 0.1*time_step;
}
}
ang_sin += speed_arm;
if(ang_sin >= 360) {
ang_sin += 360;
}
my.tilt = -max_arm+sin(ang_sin) * max_arm;
wait(1);
}
} And I get the following error: "move();" <- Bad of missing parameter
Last edited by Polypfreak1987; 07/29/08 13:45.
|
|
|
Re: A little "wait" problem
[Re: Polypfreak1987]
#219001
07/31/08 16:38
07/31/08 16:38
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
you've gone a little AWOL with you're brackets... function move() {
if(arm01) {
wait(-1);
}else{
if(arm02) {
wait(-2);
}else{
if(arm03) {
wait(-3);
}else{
if(arm04) {
wait(-4);
}else{
if(arm05) {
wait(-5);
}
}
}
}
}
} your elses will not follow the if command as you're closing them too early you probably don't need the else if arm05 as after arm04 it must be arm05 (i'm guessing this bit) NB: i'm sure you can call a function from an action Hope this helps
|
|
|
|