Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,580 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bone rotate problem #121418
04/04/07 08:50
04/04/07 08:50
Joined: Apr 2006
Posts: 329
M
molotov Offline OP
Senior Member
molotov  Offline OP
Senior Member
M

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] #121419
04/08/07 17:54
04/08/07 17:54
Joined: Apr 2006
Posts: 329
M
molotov Offline OP
Senior Member
molotov  Offline OP
Senior Member
M

Joined: Apr 2006
Posts: 329
Can anyone help me please. It's a important part for my game.

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 Offline
Expert
xXxGuitar511  Offline
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: xXxGuitar511] #121421
04/09/07 10:59
04/09/07 10:59
Joined: Apr 2006
Posts: 329
M
molotov Offline OP
Senior Member
molotov  Offline OP
Senior Member
M

Joined: Apr 2006
Posts: 329
Thanks again xXxGuitar511, the code works perfectly.

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 Offline
Expert
xXxGuitar511  Offline
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
Re: bone rotate problem [Re: xXxGuitar511] #121423
04/10/07 08:59
04/10/07 08:59
Joined: Apr 2006
Posts: 329
M
molotov Offline OP
Senior Member
molotov  Offline OP
Senior Member
M

Joined: Apr 2006
Posts: 329
I uncomment the green line, otherwise the bone10 rotated a 180 degrees, and the upper part of my player would then be backwards. Thanks again xXxGuitar511.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1