2 registered members (AndrewAMD, VoroneTZ),
919
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Problem with "c_move" and "vec_for_vertex"
#237359
11/19/08 20:30
11/19/08 20:30
|
Joined: Jul 2007
Posts: 69
fat32
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2007
Posts: 69
|
Hi. Problem when link an object to second object but both objects don't move by c_move injunction Please help me .thanks function down_rob_func();
function right_stand_func();
function left_stand_func();
function right_stand_func();
function left_stand_func();
function right_gun_func();
function left_gun_func();
function main{
level_load("robo01.wmb");fps_max=70;
wait(3);
}
entity* don_rob_ent;
entity* up_rob_ent;
entity* stand_right_rob_ent;
entity* stand_left_rob_ent;
entity* gun_right_rob_ent;
entity* gun_left_rob_ent;
//entity* don_rob_ent;
action robo_player{
var down_point_tmp;
while(me==null){wait(1);}//wait for create me
don_rob_ent=me;
moving_robo_func();
//////////////////////////////
// create up part
vec_for_vertex(down_point_tmp,me,29);
ent_create("up_robo.mdl",down_point_tmp,down_rob_func);
//////////////////////////////
//////////////////////////////
// place camera
camera.tilt = -15; // look down at the player, play with this value
while(1){
wait(time_step);
camera.x = me.x - 350 * cos(me.pan); // 250 = distance between the player and the camera, play with this value
camera.y = me.y - 350 * sin(me.pan); // use the same value here
camera.z = me.z + 150; // place the camera above the player, play with this value
camera.pan = me.pan; // the camera and the player have the same pan angle
}
//////////////////////////////
}
function down_rob_func{
while(me==null){wait(1);}//wait for create me
var right_hand_point_tmp;
var left_hand_point_tmp;
while(me==null){wait(1);}//wait for create me
up_rob_ent=me;
}
function moving_robo_func{
var anim_percentage; // animation percentage
var movement_speed; // player's movement speed
var distance_to_ground; // the distance between player's origin and the ground
// player = my; // I'm the player
while (1)
{
my.pan += 6 * (key_a - key_d) * time; // rotate the player using the "A" and "D" keys
vec_set (temp, my.x); // copy player's position to temp
temp.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box);
movement_speed.x = 5 * (key_w - key_s) * time; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 100); // 17 = experimental value
movement_speed.z = max (-35 * time, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, glide); // move the player
c_move (up_rob_ent, movement_speed.x, nullvector, glide); // move the player
if ((key_w == off) && (key_s == off)) // the player isn't moving?
{
ent_animate(my, "stand", anim_percentage, anm_cycle); // play the "stand" animation
}
else // the player is moving?
{
ent_animate(my, "walk", anim_percentage, anm_cycle); // play the "walk" animation
}
anim_percentage += 5 * time; // 5 = animation speed
wait (1);
}
}
Last edited by fat32; 11/20/08 17:55.
dobidob hosein_dig and max_man7000 game HAPPY NEW YEAR !!
|
|
|
Re: Problem with "c_move" and "vec_for_vertex"
[Re: fat32]
#237599
11/20/08 21:12
11/20/08 21:12
|
Joined: May 2006
Posts: 53 Puerto Rico
monchito
Junior Member
|
Junior Member
Joined: May 2006
Posts: 53
Puerto Rico
|
Hi, hope this help Maybe you need to update the position of 2nd part every frame. The location of vertex 29 must be evaluated every time and the position assigned to the corresponding part.Not only at initialization, must be in a loop. You only need one c_move and one must be passable. loop { // perform movement of one entity c_move (don_rob_ent, movement_speed, nullvector, // evaluate new position of vertex #29 vec_for_vertex(tmp,don_rob_ent,29); // reposition 2nd entity using the above location vec_set (up_rob_ent.x, tmp.x); wait(1); } [/code]
////////////////////////////////////////////////////////////////////
string work01_wmb = <yourlevel.wmb>;
entity* don_rob_ent;
entity* up_rob_ent;
function moving_robo_func();
function robo_player();
////////////////////////////////////////////////////////////////////
function main()
{
fps_max = 50;
level_load (work01_wmb);
wait(5);
ent_create ("dn_robo.mdl", vector(0,0,0), robo_player);
}
function robo_player()
{
var down_point_tmp;
don_rob_ent = me;
my.passable = on; /// Avoid interference when moving!!
//////////////////////////////
// create up part
vec_for_vertex(down_point_tmp,me,29);
up_rob_ent = ent_create("up_robo.mdl",down_point_tmp,NULL);
//////////////////////////////
moving_robo_func();
//////////////////////////////
// place camera
camera.tilt = -15; // look down at the player, play with this value
while(1)
{
wait(time_step);
camera.x = me.x - 350 * cos(me.pan); // 250 = distance between the player and the camera, play with this value
camera.y = me.y - 350 * sin(me.pan); // use the same value here
camera.z = me.z + 150; // place the camera above the player, play with this value
camera.pan = me.pan; // the camera and the player have the same pan angle
}
}
function moving_robo_func()
{
var anim_percentage; // animation percentage
var movement_speed; // player's movement speed
var distance_to_ground; // the distance between player's origin and the ground
var down_point_tmp;
while (1)
{
my.pan += 6 * (key_a - key_d) * time; // rotate the player using the "A" and "D" keys
vec_set (temp, my.x); // copy player's position to temp
temp.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box | ignore_you);
movement_speed.x = 5 * (key_w - key_s) * time_step; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 100); // 17 = experimental value
movement_speed.z = max (-35 * time, movement_speed.z); // 35 = falling speed
// move one entity
c_move (don_rob_ent, movement_speed, nullvector, glide); // move the player
// you need to get the position of this vertex every time
vec_for_vertex(down_point_tmp,don_rob_ent,29);
// you need to set the position of this entity every time
// reposition 'p_rob_ent' using the above location
vec_set (up_rob_ent.x, down_point_tmp.x);
if (key_w && key_s) // the player is moving?
{
ent_animate(don_rob_ent, "walk", anim_percentage, anm_cycle); // play the "walk" animation
}
else // the player is not moving?
{
ent_animate(don_rob_ent, "stand", anim_percentage, anm_cycle); // play the "stand" animation
}
anim_percentage += 5 * time; // 5 = animation speed
wait (1);
}
}
[code]
|
|
|
|