Posted By: delinkx
problem with stairs and random walk - 08/05/09 04:07
hello,
i am making my characters walk randomly in an empty room. if there is a stair they need go over it and step down if required (i.e. their feet always clamped to ground).
i have managed to do tat, but then i want when 2 entities hit each other, they pan randomly and continue their motion. when i use trace_hit, then the entity doesnt climb the stairs. it finds it as a obstacle. I tried all the stair case examples i could find in the forum but doesnt work.
here is the code:
The level is an empty room with 4 walls and cubes placed around for the entities to walk over it and step down back 2 ground.
i am making my characters walk randomly in an empty room. if there is a stair they need go over it and step down if required (i.e. their feet always clamped to ground).
i have managed to do tat, but then i want when 2 entities hit each other, they pan randomly and continue their motion. when i use trace_hit, then the entity doesnt climb the stairs. it finds it as a obstacle. I tried all the stair case examples i could find in the forum but doesnt work.
here is the code:
Code:
/////////////////////////////// //includes #include <acknex.h> //contains all the predefined structures #include <default.c> //mouse and controls predefined //#include "mtlFX.c" //material & shaders /////////////////////////////// //global variables STRING* strLevel = "Gtest.WMB"; STRING* strModel = "agent.MDL"; ENTITY* entAgent[1000]; var run_percentage; var agent_count = 0; var mygravity; int no_of_agents = 100; //action for walk animation of entity action entity_walk() { var walk_percentage; var move_result; var pan_count = 0; var speed_down = 0; VECTOR vFeet; vec_for_min(vFeet,me); wait(1); while(1) { pan_count = 0; c_move (my, nullvector, vector(0,0,10), IGNORE_PASSABLE); c_move (my, vector(7 * time_step, 0, 0), nullvector, IGNORE_PASSABLE); c_move (my, nullvector, vector(0,0,-10), IGNORE_PASSABLE); //walk animation sequence ent_animate(me,"walk",walk_percentage, ANM_CYCLE); //collision detection and resolution if (event_type == EVENT_ENTITY) { me.pan = random(360); pan_count += 1; wait(1); } // // if(trace_hit != 0) // { // // me.pan = random(360); // pan_count += 1; // wait(1); // // } // walk_percentage += 4 * time_step; wait(1); } } //funtion to load entities function load_entity() { randomize(); var ran_pos_x, ran_pos_y; var i, j; for(i=0; i<no_of_agents; i++) { wait(1); ran_pos_x = random(3000)-1710; ran_pos_y = random(3000)-1642; //create entity entAgent[i] = ent_create(strModel, vector(ran_pos_x,ran_pos_y,-240), entity_walk); agent_count +=1; //scale entity entAgent[i].scale_x = 2; entAgent[i].scale_y = 2; entAgent[i].scale_z = 2; entAgent[i].pan = random(360); //setting bounding box to tight fit for better collision detection0 //wait(1); c_setminmax(entAgent[i]); //set shadows on set(entAgent[i], SHADOW); } } //main function function main() { //800x600 screen resolution video_mode = 6; //1-fullscreen, 2-window mode video_screen = 2; //mouse mode mouse_mode = 1; max_entities = 1000; //loading level level_load(strLevel); wait(2); //call function to create agent load_entity(); }
The level is an empty room with 4 walls and cubes placed around for the entities to walk over it and step down back 2 ground.