|
c_trace issue
#283160
08/06/09 07:47
08/06/09 07:47
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
OP
User
|
OP
User
Joined: Jul 2008
Posts: 553
Singapore
|
hi, i am trying to make my entity scan a step and move over it. see the image: i trace once(trace1) from (min_x,min_y,min_z) to (min_x+10, min_y, min_z) 2nd trace(trace2) is from (min_x,min_y, min_z) to (min_x+10, min_y, min_z+100) the entity will go up (my.z = my.z+100) if trace 1 > 0 and trace2 = 0; but my traces giving me values of zero for all. here my code:
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, vector(7 * time_step, 0, 0), nullvector, GLIDE);
trace1 = c_trace(vector(my.min_x,my.min_y,my.min_z), vector(my.min_x+10,my.min_y,my.min_z), IGNORE_SPRITES);
trace2 = c_trace(vector(my.min_x,my.min_y,my.min_z), vector(my.min_x+10,my.min_y,my.min_z+100), IGNORE_SPRITES);
if(trace1 > 0 && trace2 = 0)
my.z += 100;
//walk animation sequence
ent_animate(me,"walk",walk_percentage, ANM_CYCLE);
walk_percentage += 4 * time_step;
wait(1);
}
}
my above test case involves an empty room. few cubes placed around on the floor.
|
|
|
Re: c_trace issue
[Re: delinkx]
#283168
08/06/09 08:30
08/06/09 08:30
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
OP
User
|
OP
User
Joined: Jul 2008
Posts: 553
Singapore
|
ok. while experimenting. i realise that my.min_x, etc are local cordinates. i updated my code to use this:
c_move (my, vector(7 * time_step, 0, 0), nullvector, GLIDE);
trace1 = c_trace(vector(my.x,my.y,my.z), vector(my.x+20,my.y,my.z), USE_BOX);
trace2 = c_trace(vector(my.x,my.y,my.z), vector(my.x+20,my.y,my.z+100), USE_BOX);
if(trace1 > 0 && trace2 = 0)
my.z += 100;
Now wat happens, is few entities keep sliding along the steps and after a few tries it moves up (z+100). some still cant go, they keep sliding along the steps.
|
|
|
Re: c_trace issue
[Re: delinkx]
#283217
08/06/09 15:31
08/06/09 15:31
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
try adding IGNORE_CONTENT in the c_trace
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: c_trace issue
[Re: delinkx]
#283320
08/07/09 07:26
08/07/09 07:26
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
well, you know about GLIDE, do you? If the entity origin is in the middle of the model (which it should be. Open it in MED and move the model until the origin is right in his stomach somewhere) then using c_move with GLIDE as a mode lets the entity move up stairs. Sounds like a simpler method.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: c_trace issue
[Re: Rich]
#283522
08/08/09 09:19
08/08/09 09:19
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Hm. This code placing the entity onto the ground may stop it from moving up the steps. Try commenting it out and place a "-1*time_step" into the c_move function for the absolute z value. example:
vec_set(temp,vector(my_moveSpeed*time_step,my_strafe*time_step,0));
c_move(my,temp,vector(0,0,-time_step),GLIDE); //glide is important
Just for testing purpose. And comment out all of this: trace1 = c_trace(vector(my.x,my.y,my.z), vector(my.x+20,my.y,my.z), USE_BOX); trace2 = c_trace(vector(my.x,my.y,my.z), vector(my.x+20,my.y,my.z+100), USE_BOX); if(trace1 > 0 && trace2 = 0) my.z += 100;
just to make sure it works this way, then you can go from there...?
Edit: and if it still doesn't work, try replacing the vector(0,0,-time_step) with "nullvector" again.
Last edited by Germanunkol; 08/08/09 09:19.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: c_trace issue
[Re: Germanunkol]
#283981
08/11/09 02:42
08/11/09 02:42
|
Joined: Jul 2008
Posts: 553 Singapore
delinkx
OP
User
|
OP
User
Joined: Jul 2008
Posts: 553
Singapore
|
Thnx all. Now i get the entity to move up the stairs. Both methods works: 1. Putting the entity's origin at its body center. 2. and the method of Germanunkol using-1*time_step. But now, if i put the code to put back the entities to the ground it stops climbing up. with both methods. here is the rectified code:
c_move (my, vector(7 * time_step, 0, 0), nullvector, GLIDE);
trace1 = c_trace(vector(my.x,my.y,my.z), vector(my.x+20,my.y,my.z), IGNORE_CONTENT);
trace2 = c_trace(vector(my.x,my.y,my.z), vector(my.x+20,my.y,my.z+100), IGNORE_CONTENT);
if(trace1 > 0 && trace2 = 0)
my.z += 100;
//keeping entity on ground
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME|IGNORE_SPRITES|IGNORE_CONTENT);
my.z = hit.z - my.min_z;
if i remove the code for keeping entity on ground, then it can climb. with that it doesnt. even if i use the method by Germanunkol.
|
|
|
|