2 registered members (OptimusPrime, AndrewAMD),
14,580
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
bone rotate problem
#121418
04/04/07 08:50
04/04/07 08:50
|
Joined: Apr 2006
Posts: 329
molotov
OP
Senior Member
|
OP
Senior Member
Joined: Apr 2006
Posts: 329
|
I'm using the following part of code to tilt the upper part of a entity. The idear is to trace from the camera view, from a closeby point to one far away. The entity is having a bone skeleton and bone 10 should tilt according to the target coming from the trace. The code I'm using;
{ 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; result = trace(temp3,temp4); bone_angle.tilt = ((target.z+120) * time)/6; ent_bonerotate(my,"Bone10", bone_angle); // rotate the bone named "Bone10" }
The problem is that's not working right, when I point the camera upwards the bone tilts correctly, but when I point the camera downwards the bone stops to tilt. Does anyone have a better code to do this or knows how I can fix this? Thanks anyway, Molotov.
|
|
|
Re: bone rotate problem
[Re: molotov]
#121420
04/08/07 21:37
04/08/07 21:37
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Code:
Function PointTo(&_Target) { var tPos[3]; var tAng[3]; ent_bonerotate(my, "Bone10", nullvector); vec_diff(tPos, _Target, my.x); vec_to_angle(tAng, tPos); //vec_sub(tAng, my.pan); ent_bonerotate(my, "Bone10", tAng); }
The line in red might be necessary, but I'm not sure. Just uncomment it if the script doesn't work the first time. Just pass the target position to the function, and it will rotate Bone10 to face it...
xXxGuitar511 - Programmer
|
|
|
Re: bone rotate problem
[Re: molotov]
#121422
04/09/07 17:04
04/09/07 17:04
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Kool, your welcome...
Did you have to uncomment the green line? The manual said bones rotate to absolute positions, but it could mean absolutely relative to the models... lol.
xXxGuitar511 - Programmer
|
|
|
|