3 registered members (Quad, VoroneTZ, 1 invisible),
862
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Slightly complicated ent_create
[Re: SamstaUK]
#238188
11/25/08 13:52
11/25/08 13:52
|
Joined: Jul 2007
Posts: 48
MattyTheG
Newbie
|
Newbie
Joined: Jul 2007
Posts: 48
|
This should be a pretty simple use of the ent_create() function. In your player's action you should have a while loop that waits for the player to press enter, when it does call the ent_create. I will give you a quick example of how I would do it, though I'm pretty new myself.
action cube_fall()
{
//Put random physics code or whatever you want the cube to do in here, this will be the cube's behavior.
}
action control_player() // Behavior assigned to the player
{
while(1)
{
if (key_enter == 1)
{
ent_create("cube.mdl", vector(my.x - 50, my.y, my.z), cube_fall); // creates the cube 50 quants behind the player and assigns its behavior.
wait(200); // keeps the player from making a bunch of them at once.
}
wait(1);
}
Hope you could understand that, I tried to comment it well enough. If I was you I would have a variable that keeps track of the number of cubes so that the player doesn't make a bunch and slow down/crash the game.
|
|
|
Re: Slightly complicated ent_create
[Re: MattyTheG]
#238192
11/25/08 14:14
11/25/08 14:14
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
while(key_enter ==1) wait(1);
instead of
wait(200); // keeps the player from making a bunch of them at once.
will create only one entity everytime user presses enter.
3333333333
|
|
|
Re: Slightly complicated ent_create
[Re: MattyTheG]
#238208
11/25/08 17:16
11/25/08 17:16
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
// on error = my.x - 50 != behind pos
// example only: This code SHOULD NOT work.
var behind_v[3] = {0,0,0}; // reusable
action cube_fall() {
//Put random physics code or whatever you want the cube to do in here, this will be the cube's behavior.
}
action player_a() {// Behavior assigned to the player
var kin_create; kin_create = 0;
while(1) {
if (key_enter == 1 && kin_create == 0) { //& not pressed last frame
vec_for_angle(behind_v, vector(ang(my.pan - 180), 0, 0));
vec_scale(behind_v, 50);
ent_create("cube.mdl", behind_v, cube_fall); // creates the cube 50 quants behind the player and assigns its behavior.
}
}
kin_create = key_enter; // key_enter pressed last frame?
wait(1);
}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|