bone rotate

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.
Posted By: Helghast

Re: bone rotate - 05/20/07 20:51

you have to reset the bone every frame to it's original position again.
ent_bonereset_all or something it's called.
look it up in the manual.

regards,
Posted By: molotov

Re: bone rotate - 05/21/07 07:21

Thanks dennis_fantasy for your fast reply. Anyway putting ent_bonereset in it doesn't help, i've already tried that. Thanks anyway, Molotov.
Posted By: tompo

Re: bone rotate - 05/21/07 11:02

This is a FPP or TPP ?

1. IF FPP you can trace from player and not from camera
2. If TPP you may trace from camera not from 10 quants front of camera
Maybe something like this:
Code:

ent_animate(me,NULL,0,0);
vec_set(temp,target.x);
vec_sub(temp,my.x);
vec_to_angle(tAng,temp);
ent_bonarotate(my,"bone22", tAng);


Posted By: molotov

Re: bone rotate - 05/21/07 13:43

Hey Tompo, thanks for your reply. Your code does the same as my code part. The effect what occurs is that the bone22 pan's according to the camera.pan. What I want is that the bone22 tilt's according tot the camera.tilt. And then points towards the target.x. Hope this makes any sense.

By the way, it's a TPP and I changed the 10 quants to 1000, but it still doesn't work. Thanks anyway, Molotov.
Posted By: molotov

Re: bone rotate - 05/24/07 09:00

Is there anyone that can help me, help would be much appreciated. Thanks anyway, Molotov.
© 2023 lite-C Forums