Posted By: molotov
bone rotate - 05/20/07 18:25
A time ago I posted a similiar question on this forum about bone rotation. The response on that post resulted in the following code, which worked for my previous project. But now I implemented it in a other project and now I get weird results. Here's the code;
var temp3[3];
var temp4[3];
var bone_angle[3]; // a vector that will hold the pan, tilt and roll angles
temp3.x = (screen_size.x / 2);
temp3.y = (screen_size.y / 2);
temp3.z = 10;
vec_for_screen(temp3,camera);
temp4.x = (screen_size.x / 2);
temp4.y = (screen_size.y / 2);
temp4.z = 8000;
vec_for_screen(temp4,camera);
trace_mode = ignore_me+ignore_passable;
target = trace(temp3,temp4);
var tPos[3];
var tAng[3];
ent_bonerotate(my, "bone22", nullvector);
vec_diff(tPos, Target, my.x);
vec_to_angle(tAng, tPos);
vec_sub(tAng, my.pan);
ent_bonerotate(my, "bone22", tAng);
The function should rotate bone22 in such way it points to the target position. The target is based on a trace between two points in the camera view. When I use this code in my new project it rotates the bone22 in every direction. Hope someone can tell me what's wrong with my code? Thanks anyway, Molotov.
var temp3[3];
var temp4[3];
var bone_angle[3]; // a vector that will hold the pan, tilt and roll angles
temp3.x = (screen_size.x / 2);
temp3.y = (screen_size.y / 2);
temp3.z = 10;
vec_for_screen(temp3,camera);
temp4.x = (screen_size.x / 2);
temp4.y = (screen_size.y / 2);
temp4.z = 8000;
vec_for_screen(temp4,camera);
trace_mode = ignore_me+ignore_passable;
target = trace(temp3,temp4);
var tPos[3];
var tAng[3];
ent_bonerotate(my, "bone22", nullvector);
vec_diff(tPos, Target, my.x);
vec_to_angle(tAng, tPos);
vec_sub(tAng, my.pan);
ent_bonerotate(my, "bone22", tAng);
The function should rotate bone22 in such way it points to the target position. The target is based on a trace between two points in the camera view. When I use this code in my new project it rotates the bone22 in every direction. Hope someone can tell me what's wrong with my code? Thanks anyway, Molotov.