Cbabe and stairs

Posted By: Erick_Castro

Cbabe and stairs - 12/19/09 15:50

This is a good and useful example of Cbabe coming against player and running up the stairs. A good example of c_trace

Look the video, and after download the file. Enjoy it!
http://www.youtube.com/watch?v=HoagewEYqgw

this the same code aplied to other model
http://www.youtube.com/watch?v=4pCwvXh5ukU


Download here. Run , and wait to see how Cbabe is walking on the stairs.

http://www.prodigweb.com/descargas/base.rar
Posted By: Quad

Re: Cbabe and stairs - 12/19/09 16:42

she can't climb up the stairs :X ?

also do not set fullscreen with such low resolution.
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/19/09 16:50

Yes, quadraxas. She does. That is the reason why the example is useful.

if you have problems try to download again and run it.
Posted By: Quad

Re: Cbabe and stairs - 12/19/09 16:54

no she still stays at same position, i can record a video of it.
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/19/09 16:58

i am using lite-C
7.21

in this momment i uploaded the example again
is a compressed file called base.rar
the .c file is calle "main"
i this momment i am testing. it
it works good. i can record a video too working good.

If someone download it and works good, please, tell us.
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/19/09 17:06

I think you have to use the Cbabe model that is compressed in the file i gave you. Because in MED i changed (moved Cbabe) the Z point of she to her feet and not to the midle of her. That is the only difference.
Posted By: Quad

Re: Cbabe and stairs - 12/19/09 17:31

i use you project nothing external. i use your c_babe, i am running main.c


maybe you can upload a compiled exe. it could be version diffence. (and why are you using 7.21 anyway wink? )
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/19/09 17:47

its a free version. i cant compile an exe file.

this video show you how it works good. I dont know why it doesnt work to you, friend.

http://www.youtube.com/watch?v=HoagewEYqgw

I ask for others downloaders friends tell me if it works or not.
Posted By: Quad

Re: Cbabe and stairs - 12/19/09 18:11

it is warez version. free version can compile exe. and free version uses 7.70 version of the engine.
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/19/09 18:19

well, I didnt know the version that i am using is not the official free version.
i didnt know the official free version compile exe files.
i have a foulder with severals downloaded versions from the official site.

But, the question is, did you see the video?
it works good.

I ask for some others friends to test the contribution.
Posted By: Progger

Re: Cbabe and stairs - 12/19/09 19:33

it worked fine by me but the level isnt as big as in the video
i have only the stairs but it is good (:
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/19/09 20:47

progger, i am glad it works to you.
Try to dowonload it again.
I uploaded the same of the video.
Posted By: joh

Re: Cbabe and stairs - 12/20/09 15:50

It's working but i haven't try it to other file though... can't i use other model for it?
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/20/09 18:56

Of course, joh. You have to change the model Z point to the base of the model
I changed (moved) in MED the Z position of cbabe to her feet.
look in this picture the only change you have to make to any model.

http://www.prodigweb.com/descargas/babebase.jpg

So, when you aply this code to any other model , be sure about make that.
and the model you are using have the "run" animation frames and "idle" or "stand" animation frames.


Posted By: Erick_Castro

Re: Cbabe and stairs - 12/20/09 19:13

Joh
this is another example of the same code aplied to other model.
Look

http://www.youtube.com/watch?v=4pCwvXh5ukU
Posted By: Redeemer

Re: Cbabe and stairs - 12/20/09 20:14

This code would be better if the origin didn't have to be placed at the model's feet. If the origin is at the model's feet, the model will easily move through ceilings and stuff, which looks really bad.

You should create bounding boxes for your entities instead, and leave their origin in the center.
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/20/09 21:16

i dont understand your point, redeemer. The model cant go trough walls or ceilings. I think the origin at the feet is more logical than the midlle. Do you have some better example to share. I would like if somebody else can help us to improve it.

Thanks
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/20/09 22:11

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.
Posted By: joh

Re: Cbabe and stairs - 12/21/09 08:04

im having problem with my stairs can you help me? my stairs is floating frown that's why i can't try my character to climb on it

function control_stairs(){
my.passable = off;
my.push = 100;
my.scale_x = 1;
my.scale_y = 1;
my.scale_z = 1;



my.x = 100;
my.y = 100;
my.z = 100;
}
Posted By: slacer

Re: Cbabe and stairs - 12/21/09 09:54

The idea to have the models origin NOT at their feet, is to be able to walk up stairs and to prevent from stuck in a terrain or uneven block dungeon.

There should be lot of scripts showing how to use min_z and floor in order to glue the model to the ground without sinking in the floor or floating above it.

Try solid stairs to see if your model is capable to climb the stairs. If the models origin is below the stairs surface, it will not climb it.
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/21/09 15:23

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);
}
}
}
Posted By: txesmi

Re: Cbabe and stairs - 12/25/09 17:01

its right, that was my code!

I'm not a experienced neither a talented codder, but here is the originaal code:

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!
Posted By: Erick_Castro

Re: Cbabe and stairs - 12/25/09 17:04

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."


© 2024 lite-C Forums