attach weapon to player

Posted By: kasimir

attach weapon to player - 01/15/08 12:19

Hello - i found this code to attach a weapon to the player... it works but sometimes it is not correct. The Code uses two vertex to orient the weapon, but i think if its possible to use tree vertes it will work fine! So Someone knows a better code???

Code:
 
while(player)
{
vec_for_vertex(temp.x,player,145);
vec_for_vertex(temp2.x,player,141);

vec_set(my.x,temp.x);
vec_diff(temp.x,temp2.x,temp.x);
vec_to_angle(temp.pan,temp.x);
vec_set(my.pan,temp.pan);

wait(1);
}



THX kasimir
Posted By: Mythran

Re: attach weapon to player - 01/15/08 17:17

You have to declare another temp... temp[3]
then vec_for_vertex(temp3.x,player,123) //or whatever the vertex is...

But you could just change the two vertex you have of the player hand
to fit better... no need for more vertex...
Posted By: kasimir

Re: attach weapon to player - 01/15/08 18:53

Thx but I definite need 3 vertex to change all angels of the weapon...
i know that i need 3 temp - vars ...
but i don't know how to calculate the angels exactly...
Posted By: flits

Re: attach weapon to player - 01/15/08 18:53

dont know why you didt it but the .x isnt imported

Code:


while(player)
{
vec_for_vertex(temp,player,145);
vec_for_vertex(temp2,player,141);

vec_set(my.x,temp);
vec_sub(temp,temp2);
vec_to_angle(my.pan,temp);

//if its pan 180 to much
//vec_set(my.x,temp);
//vec_sub(temp2,temp);
//vec_to_angle(my.pan,temp2);


wait(1);
}


Posted By: raiden

Re: attach weapon to player - 01/16/08 00:26

Not sure if you saw this one I did awhile back, but the Customize Menu makes it pretty easy to set items up.

Attach Items

-raiden
Posted By: raiden

Re: attach weapon to player - 01/16/08 05:37

I don't see why you need 3 vertex's to change the angles, you would want to align the weapon origin to a single vertex position of the entity(like a vertex in it's right hand) and also update the weapons angles according to the entity's angles. All that's left to do is add some offsets to make it look correct if you are in 3rd person view.

If you look at the Custom Panel in the post, you will see I have offsets for x,y,z and pan, tilt, roll. You can adjust these offsets to "fine tune" the position and angle to the vertex.

I may be totally missing what your asking for, but check out the demo and see if that works for you.

-raiden
Posted By: kasimir

Re: attach weapon to player - 01/16/08 09:48

sry but that doesn't work the way i want!!! ... i want that the weapon rotates with the hand, that means pan, tilt and roll ... your script works with easy animations, but if he should attack it does not work fine, the weapon is faced to sky allways...

with two vertex's the gun i use allway have the same pan like the player, allthought the hand shows to the right!!!
so i need definite 3 Vertex's - one for the postion, and two to orient pan roll and tilt!!!
Posted By: FcoElizalde

Re: attach weapon to player - 02/01/09 17:39

Hi kasimir
I dont know if youŽd figured out already since last post was a year ago, but anyway, the answer to this question is in other thread:

v attach calculating roll?
Posted By: Widi

Re: attach weapon to player - 02/01/09 20:56

That is the solution that i am looking for a long time. Will try it next week. Thanks a lot
Posted By: Widi

Re: attach weapon to player - 02/02/09 21:21

It works !!! You are my hero
© 2024 lite-C Forums