Most asked questions

Top  Previous  Next

Q: I'd like to have a dynamic light source that changes its color gently between 2 specified RGB colors. How can I do that?

A: Here's an example for a light source that increases and decreases each of its RGB values slowly.

 

action my_custom_light

{

   var red_min = 230; // smallest value for red

   var red_max = 255; // biggest value for red

   var green_min = 65; // and so on

   var green_max = 240;

   var blue_min = 37;

   var blue_max = 74;

   my.lightrange = 100;

   while (1)

   {

      my.skill1 = red_min + (sin(total_frames * 3.5) + 1) * (red_max - red_min) / 2; // 3.5 = speed for red

      my.skill2 = green_min + (sin(total_frames * 3.5) + 1) * (green_max - green_min) / 2; // 3.5 = speed for green

      my.skill3 = blue_min + (sin(total_frames * 3.5) +1) * (blue_max - blue_min) / 2; // 3.5 = speed for blue

      my.red = my.skill1;

      my.green = my.skill2;

      my.blue = my.skill3;

      wait (1);

   }

}

 

 

Q: How would I go about writing a code to make a door open vertically kinda like a garage door? Also with some kinda switch to activate the door?

A: Use the script below:

 

var switch_on = 0;

 

action garage_door // attach it to the garage door

{

  while (switch_on == 0) {wait (1);}

  while (my.z < 300) // play with 300

  {

     my.z += 4 * time;

     wait (1);

  }

}

 

action door_switch // attach it to the door switch

{

  while (player == null) {wait (1);}

  // wait until the player has come closer than 50 quants to the switch

  while (vec_dist (player.x, my.x) > 50) {wait (1);}

  switch_on = 1;

}

 

 

Q: I'm having some trouble with some particle effects; on startup the engine is showing the error 1517 - no level. After clicking OK, the level is running as expected. Can anyone give me a solution?

A: Some of your functions start running before the level is loaded. Check all the starter functions (or the functions that are called from a previous level, etc) in your game and add a sleep(1) instruction at their beginning.

 

 

Q: I was going through George Pirvu's pathfinding tutorial from Aum. I used the code in Aum31 exactly as it was. If you try to use the code in any level other than the one that was provided with the tutorial, during runtime, you keep getting "invalid array index" errors. Has anyone used the code from that tutorial and made it work for themselves?

A: You need to compute your own paths.txt file for your levels. This file contains the shortest paths between any two nodes and is created when you run the compute.wdl file once. Please read the article from Aum31 for more information.

 

Q: I understand that A6 has a limit of 8 dynamic lights at the moment. I was wondering if it would be possible to use more lights by monitoring player's position in the level and removing the lights that are far away from it.

A: Here's the snippet that does what you want:

 

action bright_light // attach it to your light model / sprite

{

   my.passable = on;

   my.red = 255; // set the color here

   my.green = 255;

   my.blue = 100;

   while (1)

   {

      if (vec_dist (camera.x, my.x) < 1000)

      {

          my.lightrange = 300; // activate the light

      }

      else

      {

          my.lightrange = 0; // deactivate the light

      }

     wait (1);

   }

}

 

 

Q: I'm trying to figure out how to get a model of a person to respond to contact like a bruise.

A: Use the painting code from this month's beginner's corner to create a bruise and place it on the skin of your model.

 

 

Q: Any pcx file shows the black color (RGB: 0,0,0) transparent. Is this a problem with my computer? How can I fix it?

A: That's Acknex's normal behavior. Use RGB >= 888 for your pcx files to create the opaque black color.

 

 

Q: I have trees, bushes and grass textures. How do I turn them into tga sprites with transparent backgrounds?

A: I'll use Paint Shop Pro 7 for the example below:

 

aum40_shot6

 

1) Select the entire tree, bush or grass using the magic want, point-to-point selection (my favorite method) or any other tool that does the job.

 

aum40_shot7

 

2) Invert the selection and "Cut" the result:

 

aum40_shot8

 

3) Fill the selection with black (RGB = 000) color:

 

aum40_shot9

 

4) Invert the selection again, contract the selection by 1 pixel to get rid of the black outline, and then save the result to the alpha channel:

 

aum40_shot10

 

5) Save the resulting bitmap as a tga file and place it in your level:

 

aum40_shot11