|
0 registered members (),
1,012
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Action crashes when event_type changes value
[Re: Artisan_Horstman]
#248203
01/25/09 10:39
01/25/09 10:39
|
Joined: May 2008
Posts: 331 Lithuania, Vilnius
Jaxas
Senior Member
|
Senior Member
Joined: May 2008
Posts: 331
Lithuania, Vilnius
|
I think you don't define your bounce_event, and more, you even try to look an example in manual (Lite-C). So take a look now:
// The following example shows how to use events for an object that flies ahead until it collides with a block or entity.
// The event function then plays a collision sound and lets the object ricochet from the surface.
function bounce_event()
{
switch (event_type)
{
case EVENT_BLOCK:
ent_playsound(my,whamm,50);
vec_to_angle(my.pan,bounce); // change direction
return;
case EVENT_ENTITY:
ent_playsound(my,boingg,50); // play a different sound
vec_to_angle(my.pan,bounce); // change direction
return;
}
}
action bounceball()
{
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); // make entity sensitive for block and entity collision
my.event = bounce_event;
while(1)
{
c_move(me,vector(5*time_step,0,0),nullvector,0); // move ahead until obstacle is hit
wait(1);
}
}
Analyse it, and you'll understand the structure of event. And remember, firstly search in manual, and then in forum  Jaxas
The smaller the bug, the harder it is to kill. _________________________________________ Forklift DEMO (3dgs)
|
|
|
Re: Action crashes when event_type changes value
[Re: Artisan_Horstman]
#248322
01/26/09 02:05
01/26/09 02:05
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Try this.. action balla()
{
my.emask |= ENABLE_BLOCK;
my.event = bounce_event;
while (!key_space) {wait(1);}
while (event_type != EVENT_BLOCK)
{
c_move(my, vector(0, 4 * time_step, 0), nullvector, GLIDE);
wait(1);
if(my==NULL) break; //just in case entity is destroyed alsewhere
}
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|