Most asked questions

Top  Previous  Next

Q: What is the easiest method of creating a game like Virtua Cop? I want to use a lightgun so very simply put I need to just be able to "mouse click" on an enemy to kill it.
A: Use something like this:

 

function enemy_dies()
{
       beep;
       // put the code that makes your enemies die here
       // change its animation frames, add some points to player's score, and so on
}

 

action my_enemy
{
       my.enable_click = on;
       my.event = enemy_dies;
}

 

 

Q: I don't like it when all files are in a single folder so I would want something like this.
- scripts
- graphics
- models
I don't want to use absolute paths, because the game can't find the scripts if I move the published game to a different folder. Can you help?
A: Use this example for relative paths:

path "..\\scripts";
path "..\\graphics";
path "..\\models";

 

 
Q: Why does the engine think that my models are at a different place than where I put them in Wed?
A: Make sure that the origin is set in the center of the model. If this doesn't fix the problem remove their associated actions, build and run the level that way; the code you are using might move them to a wrong position.

 

 

Q: How can I attach a fps camera to an entity, say a car for example?
A: Use this snippet:

 

starter first_person_camera() // that's a 3rd person camera really
{
       while (player == null) {wait (1);}
       while (1)
       {
               camera.x = player.x + 5 * cos(player.pan); // place the camera 5 quants in front of the player's model
               camera.y = player.y + 5 * sin(player.pan); // play with 5; keep the same value for both "cos" and "sin" lines
               camera.z = player.z + 10; // place the camera 10 quants above player's origin (play with 10)
               camera.pan = player.pan;
               camera.tilt = player.tilt;
               camera.roll = player.roll;
               wait (1);
       }
}

 

 

Q: I am having some difficulty clipping my particles in my level; it seems that no matter how I change my script the particles are not clipping.
A: Use the example below; press "U", "I", "O" and "P" and play with them until you are happy with the result. Don't forget that clip_particles is multiplied by 1000 in my example.

 

text clip_txt
{
       layer = 5;
       pos_x = 10;
       pos_y = 10;
       font = _a4font;
       string = "Clip range:\nParticle range:";
       flags = visible;
}

 

panel clip_pan
{
       layer = 5;
       digits = 100, 10, 6, _a4font, 1, clip_range; // displays the "clip_range" value
       digits = 100, 20, 6, _a4font, 1000, clip_particles; // displays the "clip_particles" value multiplied by 1000
       flags = overlay, refresh, visible;
}

 

starter clip_them()
{
       while (1)
       {
               if (key_u == on)
               {
                       clip_range += 10 * time;
               }
               if (key_i == on)
               {
                       clip_range -= 10 * time;
               }
               clip_range = min(max(clip_range, 1000), 500000); // make sure that clip_range stays in this range: 1,000...500,000
               if (key_o == on)
               {
                       clip_particles += 0.01 * time;
               }
               if (key_p == on)
               {
                       clip_particles -= 0.01 * time;
               }
               clip_particles = min(max(clip_particles, 0), 1); // make sure that clip_particles stays in this range: 0...1
               wait (1);
       }
}

 

aum48_questions1

 

 

Q: How can I remove all the entities from a level, even if they don't have an action attached to them?
A: Here's a brute-force method; prepare to deal with some empty pointers ;)

 

function remove_entities
{
       you = ent_next(null); // we retrieve the first entity
       while (1)
       {
               if (you != null) {ent_remove(you);} // if we can find an entity let's remove it
               wait (1); // we wait until the "you" pointer is valid again (if there are more entities left)
               you = ent_next(you); // we move on to the next entity
       }
}

 

on_r = remove_entities; // press the "R" key to remove all the entities

 

 

Q: If my character starts the game facing one way how can I make it so she only walks the way she is facing and can't turn?
A: Use this example:

 

action she
{
       while (1)
       {
               temp.x = 5 * time; // 5 sets the speed
               temp.y = 0;
               temp.z = 0;
               move_mode = ignore_passable;
               if (key_a == on) // press the "A" key to move her
               {
                       ent_move (temp, nullvector); // move in the direction given by the pan angle in Wed
                       ent_cycle("walk", my.skill1); // animate the model
                       my.skill1 += 5 * time; // animation speed
                       my.skill1 %= 100; // loop the animation
               }
               wait (1);
       }
}