1 registered members (AndrewAMD),
1,213
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Help with action/animation not completing at once!
#223847
08/26/08 22:47
08/26/08 22:47
|
Joined: Aug 2008
Posts: 218 U.S.
GamerX
OP
Member
|
OP
Member
Joined: Aug 2008
Posts: 218
U.S.
|
Ok so i am new to game studio and i decided after reading the tut i should start off with something simple. So i decided to make a simple game were you simply attack a target and it dies, so i decided to start off with making a little script that when the character runs into another the character hit dies. My only problem is when i run into him i have to keep running into him for him to complete his death animation or it just stops. Here is the script: ///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
var walk_percentage;
var death_percentage;
ENTITY* gurad1;
ENTITY* guard2;
var health;
function main()
{
video_mode = 7;
level_load ("work21.wmb");
wait (2); // wait until the level is loaded
camera.z = 120; // choose a convenient height
camera.tilt = -15; // and tilt angle for the camera
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function bounce_event()
{
if (event_type == EVENT_IMPACT)
{
// play a different sound
ent_animate(guard2, "death", death_percentage, 0); // "death" one-shot animation
death_percentage += 3 * time_step; // 2 = animation speed for "death"
wait (1);
return;
}
}
///////////////////////////////
action Kill_guard()
{
my.emask |= ENABLE_IMPACT;
my.event = bounce_event;
while(1)
{
if (key_w)
c_move (my, vector(15 * time_step, 0, 0), nullvector, GLIDE);
wait(1);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
action dead_guard()
{
guard2 = my;
my.emask |= ENABLE_IMPACT;
my.event = bounce_event;
} I couldn't figure out why i have to hold w when i run into him for him to complete his animation i thought he would just run the animation once he is hit but i gues it doesn't. Does any1 have an idea why? Or have a solution i would be so great full.
"You may never know what results come of your action, but if you do nothing there will be no result." -Mahatma Gandhi
|
|
|
Re: Help with action/animation not completing at once!
[Re: GamerX]
#223850
08/26/08 22:51
08/26/08 22:51
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
If i am right, because you have death_percentage, only progressing at 3% (i think) each time you press w, so you need to hold it long enough for it to reach 100%
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: Help with action/animation not completing at once!
[Re: Blade280891]
#223851
08/26/08 22:55
08/26/08 22:55
|
Joined: Aug 2008
Posts: 218 U.S.
GamerX
OP
Member
|
OP
Member
Joined: Aug 2008
Posts: 218
U.S.
|
Just makes it go faster like ALOT faster lol sounded perfect though thanks for trying.
"You may never know what results come of your action, but if you do nothing there will be no result." -Mahatma Gandhi
|
|
|
Re: Help with action/animation not completing at once!
[Re: GamerX]
#223852
08/26/08 22:59
08/26/08 22:59
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
yer, tbh i just guessed it all, i only looked at animation tutorial quick
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: Help with action/animation not completing at once!
[Re: Blade280891]
#223871
08/27/08 00:45
08/27/08 00:45
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
I havent covered in-depth animation myself, but shouldnt you put the animation in a while loop? I am guessing that is the reason it is only running once. So the part where is has...
if (event_type == EVENT_IMPACT)
{
ent_animate(guard2, "death", death_percentage, 0);
death_percentage += 3 * time_step;
wait (1);
return;
}
maybe it should be...
while(death_percentage <=100)
{
if (event_type == EVENT_IMPACT)
{
ent_animate(guard2, "death", death_percentage, 0);
death_percentage += 3 * time_step;
wait(1);
}
wait (1);
}
}
Also not quite sure why you have a return; at the end? Why do you want to exit the function?
Last edited by DJBMASTER; 08/27/08 00:45.
|
|
|
Re: Help with action/animation not completing at once!
[Re: DJBMASTER]
#223877
08/27/08 01:27
08/27/08 01:27
|
Joined: Aug 2008
Posts: 218 U.S.
GamerX
OP
Member
|
OP
Member
Joined: Aug 2008
Posts: 218
U.S.
|
The return was left over i went through a lot of changed i used the ENTITY
function thing first and it required a return i guess i forgot to get rid of it
there so much i changed at once i got mixed up.
I tried using while already but thanks thought it would work but it didn't, i saw
a few people having this same problem with shooting were they would have to hold
down the shoot key for it to complete but they didn't get any answers.
Thanks for the reply though!
"You may never know what results come of your action, but if you do nothing there will be no result." -Mahatma Gandhi
|
|
|
Re: Help with action/animation not completing at once!
[Re: GamerX]
#223880
08/27/08 01:38
08/27/08 01:38
|
Joined: Aug 2008
Posts: 218 U.S.
GamerX
OP
Member
|
OP
Member
Joined: Aug 2008
Posts: 218
U.S.
|
Ok i fixed it (sort of) i moved the while function bounce_event()
{
if (event_type == EVENT_IMPACT)
{
while (1)
{
ent_animate(guard2, "death", death_percentage, 0); // "death" one-shot animation
death_percentage += .05 * time_step; // 2 = animation speed for "death"
wait (1);
}
}
}
Last edited by GamerX; 08/27/08 02:26. Reason: fixed the speed problem
"You may never know what results come of your action, but if you do nothing there will be no result." -Mahatma Gandhi
|
|
|
Re: Help with action/animation not completing at once!
[Re: GamerX]
#224415
08/29/08 23:25
08/29/08 23:25
|
Joined: May 2006
Posts: 398
Bot190
Senior Member
|
Senior Member
Joined: May 2006
Posts: 398
|
I haven't worked with animation so this might not work but i would have a variable that would get set to 1 when the event collision happens, then change the while (1) to while (collision_var = 1). and when death_percentage = 100 change collision_var to 0. thats the only way i can think off, im sure there are better ways though.
Wait, there isn't a "Make My Game Now" button?
|
|
|
Re: Help with action/animation not completing at once!
[Re: Bot190]
#224417
08/29/08 23:36
08/29/08 23:36
|
Joined: Aug 2008
Posts: 218 U.S.
GamerX
OP
Member
|
OP
Member
Joined: Aug 2008
Posts: 218
U.S.
|
thanks but i already fixed it just using while (1)
"You may never know what results come of your action, but if you do nothing there will be no result." -Mahatma Gandhi
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|