|
Animation in While!
#174843
12/26/07 19:11
12/26/07 19:11
|
Joined: Apr 2006
Posts: 58
Moerk
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2006
Posts: 58
|
Ich habe ein kleines Random System gebaut, indem eine Zufallszahl zwischen 0 und 1 gewählt. Je nachdem welche Zahl kommt wird eine der beiden Angriffsanimationen abgespielt. Allerdings passiert bei mir da gar nichts bzw. ich sehe meine Charakter kurz "zucken" und mehr kommt nicht. Dazu muss ich sagen, ich möchte das die Animation mit nur einem Mausklick komplett einmal durchgespielt wird, ohne dass man auf der Maustaste bleiben muss. Deshalb habe ich eine While Schleife genommen. Hier der Code: Code:
function attackit { randomize(); my.attack_choose = int(random(2)); if(my.attack_choose == 0) { while (ani_attack1 <= 100) // Solange ani.... { ani_attack1 = 8 * time_step; // Ani Speed ent_animate(my, "attack", ani_attack1, anm_cycle); // Ani Bfehl wait(1); } } ani_attack1 = 0; if(my.attack_choose == 1) { while (ani_attack2 <= 100) // Solange ani.... { ani_attack2 = 8 * time_step; // Ani Speed ent_animate(my, "attack2", ani_attack2, anm_cycle); // Ani Bfehl wait(1); } ani_attack2 = 0; } }
Kennt jemand des Lösungsproblem oder gibt es da ne elegantere Methode?
"Die Kette die mich ewig hält möge man erst noch schmieden"
Regina S.
|
|
|
Re: Animation in While!
[Re: Moerk]
#174844
12/26/07 19:16
12/26/07 19:16
|
Anonymous
Unregistered
|
Anonymous
Unregistered
|
versuch mal das: Code:
function attackit { randomize(); my.attack_choose = int(random(2)); if(my.attack_choose == 0) { while (ani_attack1 <= 100) // Solange ani.... { ani_attack1 = 8 * time_step; // Ani Speed ent_animate(my, "attack", ani_attack1, anm_cycle); // Ani Bfehl ani_attack1 += 3*time;//animation speed if(ani_attack1 > 100){ani_attack1 = 0;} wait(1); } } ani_attack1 = 0; if(my.attack_choose == 1) { while (ani_attack2 <= 100) // Solange ani.... { ani_attack2 = 8 * time_step; // Ani Speed ent_animate(my, "attack2", ani_attack2, anm_cycle); // Ani Bfehl ani_attack2 += 3*time;//animation speed if(ani_attack2 > 100){ani_attack2 = 0;} wait(1); } ani_attack2 = 0; } }
|
|
|
Re: Animation in While!
[Re: Slin]
#174846
12/26/07 19:24
12/26/07 19:24
|
Anonymous
Unregistered
|
Anonymous
Unregistered
|
sry hab mir den code nicht genau angeschaut
|
|
|
Re: Animation in While!
[Re: ]
#174847
12/26/07 19:29
12/26/07 19:29
|
Joined: Apr 2006
Posts: 58
Moerk
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2006
Posts: 58
|
Funktioniert nicht... ich schätze es liegt an der While Schleife...
"Die Kette die mich ewig hält möge man erst noch schmieden"
Regina S.
|
|
|
Re: Animation in While!
[Re: flits]
#174849
12/26/07 21:25
12/26/07 21:25
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
Expert
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
|
Try this : Code:
function attackit { while(player != null) { ani_attack1_speed = 8; ani_attack2_speed = 8; randomize(); my.attack_choose = int(random(2)); if(my.attack_choose == 0) { while (ani_attack1 < 100) // Solange ani.... { ani_attack1 += (ani_attack_speed * time_step)%100; // Ani Speed ent_animate(my, "attack", ani_attack1, 0); // Ani Bfehl wait(1); } ani_attack1 = 0; } if(my.attack_choose == 1) { while (ani_attack2 < 100) // Solange ani.... { ani_attack2 += (ani_attack2_speed * time_step)%100; // Ani Speed ent_animate(my, "attack2", ani_attack2, 0); // Ani Bfehl wait(1); } ani_attack2 = 0; } wait(1); } }
If this doesn't work, try changing the 100 value into 99. Cheers Frazzle
Antec® Case Intel® X58 Chipset Intel® i7 975 Quad Core 8 GB RAM DDR3 SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB NVIDIA® GeForce GTX 295 Memory 1795GB
|
|
|
Re: Animation in While!
[Re: frazzle]
#174850
12/26/07 21:41
12/26/07 21:41
|
Joined: Apr 2006
Posts: 58
Moerk
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2006
Posts: 58
|
Well ok but i start that script in another while loop Code:
if(mouse_left && proc_status(attackit) == 0) { attackit(); } the while loop isnt a good solution in this way!
"Die Kette die mich ewig hält möge man erst noch schmieden"
Regina S.
|
|
|
Re: Animation in While!
[Re: Moerk]
#174851
12/27/07 02:29
12/27/07 02:29
|
Joined: Apr 2005
Posts: 3,076 Germany, NRW
rvL_eXile
3D Artist
|
3D Artist
Joined: Apr 2005
Posts: 3,076
Germany, NRW
|
Schau mal auf meinem Blog unter Tutorials "player with Animation Tutorial" dort wirst du sehen wie es geht cYa Sebastian P.S. Blog siehe Signatur
Tutorials: [Blender]Terrain creation ENG/GER [Blender]Low Poly Tree Modeling [GIMP]Create a Texture for Terrains CLICK HERE
|
|
|
Re: Animation in While!
[Re: rvL_eXile]
#174852
12/27/07 13:00
12/27/07 13:00
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
Quote:
Schau mal auf meinem Blog unter Tutorials "player with Animation Tutorial" dort wirst du sehen wie es geht
cYa Sebastian
P.S. Blog siehe Signatur
Sorry, aber den code kann man vergessen... Gerade wenn es darum geht etwas abzugucken.
Mir ist noch die Idee gekommen, dass es sein könnte, dass die Funktion für diese Animation zu häufig aufgerufen wird und die Animation also in kürzester Zeit abläuft. Dies passiert nähmlich durch if(key_kp) { funktion(); } in einer Schleife. Um das zu verhindern könntest du z.B. eine Variable setzen solange die Funktion ausgeführt wird und erst, wenn diese wieder 0 ist die Funktion erneut aufrufen lassen.
|
|
|
|