1 registered members (TipmyPip),
18,631
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Cbabe and stairs
[Re: slacer]
#302706
12/21/09 15:23
12/21/09 15:23
|
Joined: Mar 2009
Posts: 207
Erick_Castro
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 207
|
Friends. This Action code is for normal models that have Z point in the midle.
#define Desfase_z skill50 VECTOR temp; VECTOR vtemp; VECTOR atemp;
action robotB() { c_setminmax(me); var Distancia_Suelo = 0; var Porcentaje_Animacion = 0; var Velocidad_Vertical = 0; while( player ) { vec_diff( vtemp, player.x, my.x ); vec_to_angle( atemp, vtemp ); my.pan = atemp.pan; Distancia_Suelo = c_trace(vector(my.x,my.y,my.z + my.Desfase_z),vector(my.x,my.y,my.z - 4000), IGNORE_ME | IGNORE_PASSABLE | USE_BOX ); my.z -= Distancia_Suelo; if ( vec_length(vtemp) > 150 ) { c_move (me, vector( 8 * time_step, 0, 0 ), NULL, IGNORE_PASSABLE | GLIDE); ent_animate(my, "run", Porcentaje_Animacion, ANM_CYCLE); Porcentaje_Animacion += 6 * time_step; Porcentaje_Animacion %= 100; wait(1); } else { ent_animate(my, "stand", Porcentaje_Animacion, ANM_CYCLE); Porcentaje_Animacion += 6 * time_step; Porcentaje_Animacion %= 100; wait(1); } } }
|
|
|
Re: Cbabe and stairs
[Re: Erick_Castro]
#303128
12/25/09 17:01
12/25/09 17:01
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
its right, that was my code! I'm not a experienced neither a talented codder, but here is the originaal code:
//Variables temporales
ANGLE atemp;
VECTOR vtemp;
// CBabe
action robotico()
{
while(!player) wait(1);
c_setminmax(me);
// Variables locales
var Porcentaje_Animacion = 0;
var Velocidad_Vertical = 0;
// Colocar en el suelo
c_trace( vector( my.x, my.y, my.z + 1000 ), vector( my.x, my.y, my.z - 1000 ), IGNORE_ME | IGNORE_PASSABLE | USE_BOX );
my.z = target.z + 1;
while( player ) // Bucle principal
{
vec_diff( vtemp, player.x, my.x ); // Obtener vector de diferencia entre el jugador y my
vec_to_angle( atemp, vtemp ); // Transformar de coordenadas XYZ a coordenadas angulares Rotación/Inclinación/Alabeo
my.pan = atemp.pan; // Orientar malla según el ángulo de rotación
if ( ( vec_length(vtemp) > 150 ) || ( Velocidad_Vertical != 0 ) ) // Si está a más de 150 quants del jugador o está saltando
{
c_move (my, vector( 2 * time_step, 0, 0 ), vector( 0, 0, Velocidad_Vertical * time_step ), GLIDE ); // Mover malla
if ( trace_hit && ( Velocidad_Vertical == 0 ) ) // Si en el movimiento a tocado algo y no está saltando
{
Velocidad_Vertical = 7; // Iniciar salto
}
if ( ( c_trace( my.x, vector( my.x, my.y, my.z - 3 ), IGNORE_ME | IGNORE_PASSABLE ) > 0 ) && ( Velocidad_Vertical <= 0 ) ) // Si hay suelo cerca y no está subiendo en el salto
{
my.z = target.z + 1; // Colocar en el suelo
Velocidad_Vertical = 0; // Detener movimiento vertical
}
else // Si está en el aire
{
Velocidad_Vertical -= time_step * 2; // Aplicar gravedad
}
ent_animate(my, "walk", Porcentaje_Animacion, ANM_CYCLE); // Animar 'andar'
}
else // Si está a menos de 150 quants y no está saltando
{
ent_animate(my, "idle", Porcentaje_Animacion, ANM_CYCLE); // Animar 'parado'
}
Porcentaje_Animacion += 6 * time_step; // Aumenta el porcentaje de animación de forma constante
Porcentaje_Animacion %= 100; // Obteniendo el resto de su división por 100 conseguimos que haga un ciclo de 0 a 99.99^
wait(1);
}
ent_remove ( me );
return;
}
The main idea of this code was to perform a jump when cbabe colides with something. This way she can climb everything as tall as her maximun jump and she doesn't need glide for climbing. This code is not a solution for a following model. It is just a workaround the challenge. I think that it manages gravity and colisions quiet good in a few lines. My precarious experience tells me that sometimes the feet base point is the best suitable option for getting clean code, but i have not deeped as long as i would like to. I wrote this example for partidabierta.com - A7 spanish community Salud!
|
|
|
Re: Cbabe and stairs
[Re: txesmi]
#303129
12/25/09 17:04
12/25/09 17:04
|
Joined: Mar 2009
Posts: 207
Erick_Castro
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 207
|
Txesmi, mas arriba, si lees, notarás que a Redeemer yo le he dicho que el código ha sido escrito con tu ayuda. Lee arriba, amigo.
"Redeemer. I understood your point. well, i will work to improve it. I have to tell you this code is developed with the colaboration of a spain friend of the forum called TXesmi."
Last edited by Erick_Castro; 12/25/09 17:08.
|
|
|
|