This is the tripod in global coordinates: It has red for x axis, green for y axis and blue for z axis
Now, if I use this code I created
Code: Select all
//self is parent entity (that I've hidden in the screenshot for a clearer image), which has its own coordinates, but, in this case, it moves on global coordinates except for turning Y axis as yaw
void Orient_Think()
{
makevectors(self.angles);
traceline(self.origin,self.origin+(-v_up*128),MOVE_HITMODEL,self);
fracdown = trace_fraction;
local vector v = trace_plane_normal;
makevectors(trace_plane_normal);
vectest = vectoangles(v);
setorigin(tripod,trace_endpos);
tripod.angles = vectest;
self.nextthink = time + 1;
self.think = Orient_Think;
}
Now, I also created a code for make sure tripod turns on yaw accordingly to parent entity orientation like so
Code: Select all
makevectors(self.angles);
traceline(self.origin,self.origin+(-v_up*128),MOVE_HITMODEL,self);
fracdown = trace_fraction;
if(trace_fraction < 1){
local vector v = normalize(trace_plane_normal);
vectest = vectoangles([v_x,v_y,v_z],-v_forward);
}
setorigin(tripod,trace_endpos);
tripod.angles = vectest;
I also tried to invert axis using something like
Code: Select all
vectest = vectoangles([v_z,v_y,v_x],-v_forward);
How can I retrieve correct orientation of a trace_plane_normal and how can I manage those data to rotate the axis ternary as I want?
Thanks a lot for any clarification, because, on this subject I'm completely ignorant (it requires math..GAHHH )!